lscom 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lscom/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # | _ _ _ ._ _
4
- # | _> (_ (_) | | |
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # | _ _ _ ._ _
4
+ # | _> (_ (_) | | |
lscom/__main__.py CHANGED
@@ -1,50 +1,56 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # | _ _ _ ._ _
4
- # | _> (_ (_) | | |
5
-
6
- """
7
- lscom
8
- ~~~~~
9
-
10
- list available serial ports
11
- """
12
-
13
- import sys
14
-
15
- from lscom import helpers
16
- from lscom.__version__ import __title__, __version__
17
- from lscom.app import run
18
-
19
- PY_MAJOR = 3
20
- PY_MINOR = 2
21
- MINIMUM_PYTHON_VERISON = "3.2"
22
-
23
-
24
- def check_python_version(): # type: ignore
25
- """Use old-school .format() method for if someone uses with very old Python."""
26
- msg = """
27
-
28
- {title} version {pkgv} requires Python version {pyv} or higher.
29
- """.format(
30
- title=__title__, pkgv=__version__, pyv=MINIMUM_PYTHON_VERISON
31
- )
32
- if sys.version_info < (PY_MAJOR, PY_MINOR):
33
- raise ValueError(msg)
34
-
35
-
36
- def main():
37
- parser = helpers.setup_parser()
38
- args = parser.parse_args() # noqa: F841
39
- run()
40
-
41
-
42
- def init():
43
- check_python_version() # type: ignore
44
-
45
- if __name__ == "__main__":
46
- main()
47
- sys.exit(0)
48
-
49
-
50
- init()
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # | _ _ _ ._ _
4
+ # | _> (_ (_) | | |
5
+
6
+ """
7
+ lscom
8
+ ~~~~~
9
+
10
+ list available serial ports
11
+ """
12
+
13
+ import argparse
14
+ import sys
15
+
16
+ from lscom.__version__ import __title__, __version__
17
+ from lscom.app import run
18
+
19
+ PY_MAJOR = 3
20
+ PY_MINOR = 2
21
+ MINIMUM_PYTHON_VERISON = "3.2"
22
+
23
+
24
+ def check_python_version(): # type: ignore
25
+ """Use old-school .format() method for if someone uses with very old Python."""
26
+ msg = """
27
+
28
+ {title} version {pkgv} requires Python version {pyv} or higher.
29
+ """.format(
30
+ title=__title__, pkgv=__version__, pyv=MINIMUM_PYTHON_VERISON
31
+ )
32
+ if sys.version_info < (PY_MAJOR, PY_MINOR):
33
+ raise ValueError(msg)
34
+
35
+
36
+ def main():
37
+ parser = argparse.ArgumentParser(
38
+ formatter_class=argparse.RawDescriptionHelpFormatter,
39
+ description="lscom: list and discover available COM ports",
40
+ epilog="Made with Python by Josh Schmelzle",
41
+ )
42
+ parser.add_argument(
43
+ "--version", "-v", action="version", version=f"lscom version {__version__}"
44
+ )
45
+ args = parser.parse_args() # noqa: F841
46
+ run()
47
+
48
+
49
+ def init():
50
+ check_python_version() # type: ignore
51
+
52
+ if __name__ == "__main__":
53
+ sys.exit(main())
54
+
55
+
56
+ init()
lscom/__version__.py CHANGED
@@ -1,14 +1,14 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # | _ _ _ ._ _
4
- # | _> (_ (_) | | |
5
-
6
- """ version information for lscom """
7
-
8
- __title__ = "lscom"
9
- __description__ = "list available active COM ports"
10
- __url__ = "https://github.com/joshschmelzle/lscom"
11
- __version__ = "0.0.3"
12
- __author__ = "Josh Schmelzle"
13
- __author_email__ = "josh@joshschmelzle.com"
14
- __license__ = "MIT"
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # | _ _ _ ._ _
4
+ # | _> (_ (_) | | |
5
+
6
+ """version information for lscom"""
7
+
8
+ __title__ = "lscom"
9
+ __description__ = "list available active COM ports"
10
+ __url__ = "https://github.com/joshschmelzle/lscom"
11
+ __version__ = "0.0.4"
12
+ __author__ = "Josh Schmelzle"
13
+ __author_email__ = "josh@joshschmelzle.com"
14
+ __license__ = "MIT"
lscom/app.py CHANGED
@@ -1,109 +1,110 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # | _ _ _ ._ _
4
- # | _> (_ (_) | | |
5
-
6
- """
7
- lscom.app
8
- ~~~~~~~~~
9
-
10
- main app code
11
- """
12
-
13
- import glob
14
- import grp
15
- import os
16
- import sys
17
-
18
- try:
19
- import serial # type: ignore
20
- except ModuleNotFoundError:
21
- print("required module pyserial not found... exiting...")
22
- sys.exit(-1)
23
-
24
-
25
- class lscom:
26
- """Main application class."""
27
-
28
- def check_serial_permissions(self):
29
- """
30
- Check if current user has permissions for serial port access on Linux.
31
-
32
- Add to dialout:
33
- sudo usermod -a -G dialout $USER
34
-
35
- Remove from dialout:
36
- sudo gpasswd -d $USER dialout
37
-
38
- :returns:
39
- Tuple: (bool, message)
40
- """
41
- if not sys.platform.startswith("linux"):
42
- return True, "Permission check required"
43
-
44
- try:
45
- dialout = grp.getgrnam("dialout")
46
- groups = os.getgroups()
47
- user = os.getlogin()
48
- if dialout.gr_gid in groups:
49
- return True, f"{user} has dialout group access"
50
- else:
51
- return (
52
- False,
53
- f"""
54
- {user} is not in the dialout group. To fix:
55
- 1. Run: sudo usermod -a -G dialout {user}
56
- 2. Log out and back in for the changes to take effect
57
- """,
58
- )
59
- except KeyError:
60
- return False, "dialout group not found"
61
- except Exception as error:
62
- return False, f"Error checking permissions: {str(error)}"
63
-
64
- def get_active_serial_port_names(self):
65
- """Lists serial port names
66
-
67
- :raises EnvironmentError:
68
- On unsupported or unknown platforms
69
- :returns:
70
- A list of the serial ports available on the system
71
- """
72
- has_permissions, message = self.check_serial_permissions()
73
- if not has_permissions:
74
- print(message)
75
- if sys.platform.startswith("win"):
76
- ports = ["COM%s" % (i + 1) for i in range(256)]
77
- elif sys.platform.startswith("linux") or sys.platform.startswith("cygwin"):
78
- # this excludes your current terminal "/dev/tty"
79
- ports = glob.glob("/dev/tty[A-Za-z]*")
80
- elif sys.platform.startswith("darwin"):
81
- ports = glob.glob("/dev/tty.*")
82
- else:
83
- raise EnvironmentError(
84
- "appears to be an unsupported platform", sys.platform
85
- )
86
-
87
- result = []
88
- for port in ports:
89
- try:
90
- _serial = serial.Serial(port)
91
- _serial.close()
92
- result.append(port)
93
- except (OSError, serial.SerialException):
94
- pass
95
- return result
96
-
97
- def run(self):
98
- serials = self.get_active_serial_port_names()
99
- if len(serials) > 0:
100
- print("{0} serial ports detected and available:".format(len(serials)))
101
- for _ in serials:
102
- print(_)
103
- else:
104
- print("no available serial ports detected")
105
-
106
-
107
- def run() -> None:
108
- """Run the application."""
109
- lscom().run()
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # | _ _ _ ._ _
4
+ # | _> (_ (_) | | |
5
+
6
+ """
7
+ lscom.app
8
+ ~~~~~~~~~
9
+
10
+ main app code
11
+ """
12
+
13
+ import glob
14
+ import os
15
+ import sys
16
+
17
+ try:
18
+ import serial # type: ignore
19
+ except ModuleNotFoundError:
20
+ print("required module pyserial not found... exiting...")
21
+ sys.exit(-1)
22
+
23
+
24
+ class lscom:
25
+ """Main application class."""
26
+
27
+ def check_serial_permissions(self):
28
+ """
29
+ Check if current user has permissions for serial port access on Linux.
30
+
31
+ Add to dialout:
32
+ sudo usermod -a -G dialout $USER
33
+
34
+ Remove from dialout:
35
+ sudo gpasswd -d $USER dialout
36
+
37
+ :returns:
38
+ Tuple: (bool, message)
39
+ """
40
+ if not sys.platform.startswith("linux"):
41
+ return True, "Permission check required"
42
+
43
+ try:
44
+ import grp
45
+
46
+ dialout = grp.getgrnam("dialout")
47
+ groups = os.getgroups()
48
+ user = os.getlogin()
49
+ if dialout.gr_gid in groups:
50
+ return True, f"{user} has dialout group access"
51
+ else:
52
+ return (
53
+ False,
54
+ f"""
55
+ {user} is not in the dialout group. To fix:
56
+ 1. Run: sudo usermod -a -G dialout {user}
57
+ 2. Log out and back in for the changes to take effect
58
+ """,
59
+ )
60
+ except KeyError:
61
+ return False, "dialout group not found"
62
+ except Exception as error:
63
+ return False, f"Error checking permissions: {str(error)}"
64
+
65
+ def get_active_serial_port_names(self):
66
+ """Lists serial port names
67
+
68
+ :raises EnvironmentError:
69
+ On unsupported or unknown platforms
70
+ :returns:
71
+ A list of the serial ports available on the system
72
+ """
73
+ has_permissions, message = self.check_serial_permissions()
74
+ if not has_permissions:
75
+ print(message)
76
+ if sys.platform.startswith("win"):
77
+ ports = ["COM%s" % (i + 1) for i in range(256)]
78
+ elif sys.platform.startswith("linux") or sys.platform.startswith("cygwin"):
79
+ # this excludes your current terminal "/dev/tty"
80
+ ports = glob.glob("/dev/tty[A-Za-z]*")
81
+ elif sys.platform.startswith("darwin"):
82
+ ports = glob.glob("/dev/tty.*")
83
+ else:
84
+ raise EnvironmentError(
85
+ "appears to be an unsupported platform", sys.platform
86
+ )
87
+
88
+ result = []
89
+ for port in ports:
90
+ try:
91
+ _serial = serial.Serial(port)
92
+ _serial.close()
93
+ result.append(port)
94
+ except (OSError, serial.SerialException):
95
+ pass
96
+ return result
97
+
98
+ def run(self):
99
+ serials = self.get_active_serial_port_names()
100
+ if len(serials) > 0:
101
+ print("{0} serial ports detected and available:".format(len(serials)))
102
+ for _ in serials:
103
+ print(_)
104
+ else:
105
+ print("no available serial ports detected")
106
+
107
+
108
+ def run() -> None:
109
+ """Run the application."""
110
+ lscom().run()
@@ -1,73 +1,74 @@
1
- Metadata-Version: 2.2
2
- Name: lscom
3
- Version: 0.0.3
4
- Summary: list available active COM ports
5
- Home-page: https://github.com/joshschmelzle/lscom
6
- Author: Josh Schmelzle
7
- Author-email: josh@joshschmelzle.com
8
- License: MIT
9
- Keywords: com,com ports,serial
10
- Classifier: Natural Language :: English
11
- Classifier: Development Status :: 3 - Alpha
12
- Classifier: Programming Language :: Python :: 3.2
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Intended Audience :: System Administrators
15
- Classifier: Topic :: Utilities
16
- Requires-Python: >3.2,
17
- Description-Content-Type: text/markdown
18
- License-File: LICENSE
19
- Requires-Dist: pyserial
20
- Dynamic: author
21
- Dynamic: author-email
22
- Dynamic: classifier
23
- Dynamic: description
24
- Dynamic: description-content-type
25
- Dynamic: home-page
26
- Dynamic: keywords
27
- Dynamic: license
28
- Dynamic: requires-dist
29
- Dynamic: requires-python
30
- Dynamic: summary
31
-
32
- ![pypi-badge](https://img.shields.io/pypi/v/lscom) ![pypi-format](https://img.shields.io/pypi/format/lscom) ![pypi-implementation](https://img.shields.io/pypi/implementation/lscom) ![pypi-version](https://img.shields.io/pypi/pyversions/lscom) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/joshschmelzle/lscom/blob/main/CODE_OF_CONDUCT.md)
33
-
34
- # lscom: list and discover available COM ports
35
-
36
- More quickly identify which COM ports are available for use. Any COM ports already in use will not be listed. `lscom` should work cross platform (Linux, macOS, Windows), but has not been extensively tested. Have a problem? Open an issue.
37
-
38
- ## Usage Example
39
-
40
- ```
41
- $ lscom
42
- ['COM3']
43
- ```
44
-
45
- ## Installation from PyPI
46
-
47
- ```bash
48
- python -m pip install lscom
49
- ```
50
-
51
- ## Local Installation Example
52
-
53
- To install manually:
54
-
55
- 1. Clone repository.
56
-
57
- 2. Open the terminal to the root of the repository.
58
-
59
- 3. Run-
60
-
61
- ```bash
62
- python -m pip install .
63
- ```
64
-
65
- You should now be able to run `lscom` from your terminal
66
-
67
- If you can't, check and make sure the scripts directory is included in the system path environment variable.
68
-
69
- To remove:
70
-
71
- ```bash
72
- python -m pip uninstall lscom
73
- ```
1
+ Metadata-Version: 2.4
2
+ Name: lscom
3
+ Version: 0.0.4
4
+ Summary: list available active COM ports
5
+ Home-page: https://github.com/joshschmelzle/lscom
6
+ Author: Josh Schmelzle
7
+ Author-email: josh@joshschmelzle.com
8
+ License: MIT
9
+ Keywords: com,com ports,serial
10
+ Classifier: Natural Language :: English
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Programming Language :: Python :: 3.2
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: Topic :: Utilities
16
+ Requires-Python: >3.2,
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: pyserial
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: keywords
27
+ Dynamic: license
28
+ Dynamic: license-file
29
+ Dynamic: requires-dist
30
+ Dynamic: requires-python
31
+ Dynamic: summary
32
+
33
+ ![pypi-badge](https://img.shields.io/pypi/v/lscom) ![pypi-format](https://img.shields.io/pypi/format/lscom) ![pypi-implementation](https://img.shields.io/pypi/implementation/lscom) ![pypi-version](https://img.shields.io/pypi/pyversions/lscom) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/joshschmelzle/lscom/blob/main/CODE_OF_CONDUCT.md)
34
+
35
+ # lscom: list and discover available COM ports
36
+
37
+ More quickly identify which COM ports are available for use. Any COM ports already in use will not be listed. `lscom` should work cross platform (Linux, macOS, Windows), but has not been extensively tested. Have a problem? Open an issue.
38
+
39
+ ## Usage Example
40
+
41
+ ```
42
+ $ lscom
43
+ ['COM3']
44
+ ```
45
+
46
+ ## Installation from PyPI
47
+
48
+ ```bash
49
+ python -m pip install lscom
50
+ ```
51
+
52
+ ## Local Installation Example
53
+
54
+ To install manually:
55
+
56
+ 1. Clone repository.
57
+
58
+ 2. Open the terminal to the root of the repository.
59
+
60
+ 3. Run-
61
+
62
+ ```bash
63
+ python -m pip install .
64
+ ```
65
+
66
+ You should now be able to run `lscom` from your terminal
67
+
68
+ If you can't, check and make sure the scripts directory is included in the system path environment variable.
69
+
70
+ To remove:
71
+
72
+ ```bash
73
+ python -m pip uninstall lscom
74
+ ```
@@ -0,0 +1,10 @@
1
+ lscom/__init__.py,sha256=WtN4T7mOGywQBrXJV6LI-LVOEO4VsVYv_IDUk_ZzWFY,68
2
+ lscom/__main__.py,sha256=ZOehmKf9gxckGPnG4ZLXmWQt_KHoyS0_gFAzyjC6nJE,1245
3
+ lscom/__version__.py,sha256=jnKiHA1ZjrPVdDgBx54HmGwQU_WI26hxuE4d4ZQQEOs,355
4
+ lscom/app.py,sha256=byM7H9M7J1uWEv3XAD0Y-acPYiR1781E5V9x20r_1lk,3168
5
+ lscom-0.0.4.dist-info/licenses/LICENSE,sha256=sCQdvgDLxhhGvVufZs7UIRmNCbQTtxgILkaTTJhWZVY,1092
6
+ lscom-0.0.4.dist-info/METADATA,sha256=nIRdvB9lKwTAm1CFuqtFHSqgnzJrmPQAv-bL9GbxRfs,2148
7
+ lscom-0.0.4.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
8
+ lscom-0.0.4.dist-info/entry_points.txt,sha256=a7EcCLxFdb5WVmcy0RkzECIvPgPIumowQlEbOWoWl0k,46
9
+ lscom-0.0.4.dist-info/top_level.txt,sha256=7aXJNRvNg3caDlTXuU_fLFVJD0dhaZG84UdVRUxLqcc,6
10
+ lscom-0.0.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Josh Schmelzle
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Josh Schmelzle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
lscom/helpers.py DELETED
@@ -1,27 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # | _ _ _ ._ _
4
- # | _> (_ (_) | | |
5
-
6
- """
7
- lscom.helpers
8
- ~~~~~~~~~~~~~
9
-
10
- helper functions
11
- """
12
-
13
- import argparse
14
-
15
- from lscom.__version__ import __version__
16
-
17
-
18
- def setup_parser():
19
- """Set default values and handle arg parser."""
20
- parser = argparse.ArgumentParser(
21
- formatter_class=argparse.RawDescriptionHelpFormatter,
22
- description="lscom: list and discover available COM ports",
23
- )
24
- parser.add_argument(
25
- "--version", "-v", action="version", version=f"lscom version is {__version__}"
26
- )
27
- return parser
@@ -1,11 +0,0 @@
1
- lscom/__init__.py,sha256=ifPM1hOek6le3YZWMc0ZsuR_-oaAW3F1I8-YsT4XzyY,64
2
- lscom/__main__.py,sha256=fBr3WZSCKZf77YFl5tNveT4BPfqiLYn7MtST2-yEoUE,903
3
- lscom/__version__.py,sha256=-fANk4luWtS5MhpViB62WNuYLDctjU5mlrSHW5XpPlU,343
4
- lscom/app.py,sha256=62WUIzvAlyTKZqsZbaXuNoX1sKHRwNYjZY5N0W5OFGs,3045
5
- lscom/helpers.py,sha256=Yqtg3JBjRPsujY0hHK46GFlzWVSiew2fIuj70C1o8BI,563
6
- lscom-0.0.3.dist-info/LICENSE,sha256=kH0BjvpwBWfRwgjUIR_aL7aBaJLfp-U41rsJW1jKF8M,1071
7
- lscom-0.0.3.dist-info/METADATA,sha256=ZJ3R5N2b9CcvffGBP2np-0mr9M5nOPBrFHjOz77EOz8,2052
8
- lscom-0.0.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
- lscom-0.0.3.dist-info/entry_points.txt,sha256=a7EcCLxFdb5WVmcy0RkzECIvPgPIumowQlEbOWoWl0k,46
10
- lscom-0.0.3.dist-info/top_level.txt,sha256=7aXJNRvNg3caDlTXuU_fLFVJD0dhaZG84UdVRUxLqcc,6
11
- lscom-0.0.3.dist-info/RECORD,,