lscom 0.0.2__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/__main__.py CHANGED
@@ -10,9 +10,9 @@ lscom
10
10
  list available serial ports
11
11
  """
12
12
 
13
+ import argparse
13
14
  import sys
14
15
 
15
- from lscom import helpers
16
16
  from lscom.__version__ import __title__, __version__
17
17
  from lscom.app import run
18
18
 
@@ -34,7 +34,14 @@ def check_python_version(): # type: ignore
34
34
 
35
35
 
36
36
  def main():
37
- parser = helpers.setup_parser()
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
+ )
38
45
  args = parser.parse_args() # noqa: F841
39
46
  run()
40
47
 
@@ -43,8 +50,7 @@ def init():
43
50
  check_python_version() # type: ignore
44
51
 
45
52
  if __name__ == "__main__":
46
- main()
47
- sys.exit(0)
53
+ sys.exit(main())
48
54
 
49
55
 
50
56
  init()
lscom/__version__.py CHANGED
@@ -3,12 +3,12 @@
3
3
  # | _ _ _ ._ _
4
4
  # | _> (_ (_) | | |
5
5
 
6
- """ version information for lscom """
6
+ """version information for lscom"""
7
7
 
8
8
  __title__ = "lscom"
9
9
  __description__ = "list available active COM ports"
10
10
  __url__ = "https://github.com/joshschmelzle/lscom"
11
- __version__ = "0.0.2"
11
+ __version__ = "0.0.4"
12
12
  __author__ = "Josh Schmelzle"
13
13
  __author_email__ = "josh@joshschmelzle.com"
14
14
  __license__ = "MIT"
lscom/app.py CHANGED
@@ -11,6 +11,7 @@ main app code
11
11
  """
12
12
 
13
13
  import glob
14
+ import os
14
15
  import sys
15
16
 
16
17
  try:
@@ -23,6 +24,44 @@ except ModuleNotFoundError:
23
24
  class lscom:
24
25
  """Main application class."""
25
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
+
26
65
  def get_active_serial_port_names(self):
27
66
  """Lists serial port names
28
67
 
@@ -31,6 +70,9 @@ class lscom:
31
70
  :returns:
32
71
  A list of the serial ports available on the system
33
72
  """
73
+ has_permissions, message = self.check_serial_permissions()
74
+ if not has_permissions:
75
+ print(message)
34
76
  if sys.platform.startswith("win"):
35
77
  ports = ["COM%s" % (i + 1) for i in range(256)]
36
78
  elif sys.platform.startswith("linux") or sys.platform.startswith("cygwin"):
@@ -1,13 +1,12 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: lscom
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: list available active COM ports
5
5
  Home-page: https://github.com/joshschmelzle/lscom
6
6
  Author: Josh Schmelzle
7
7
  Author-email: josh@joshschmelzle.com
8
8
  License: MIT
9
9
  Keywords: com,com ports,serial
10
- Platform: UNKNOWN
11
10
  Classifier: Natural Language :: English
12
11
  Classifier: Development Status :: 3 - Alpha
13
12
  Classifier: Programming Language :: Python :: 3.2
@@ -16,7 +15,20 @@ Classifier: Intended Audience :: System Administrators
16
15
  Classifier: Topic :: Utilities
17
16
  Requires-Python: >3.2,
18
17
  Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
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
20
32
 
21
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)
22
34
 
@@ -31,7 +43,7 @@ $ lscom
31
43
  ['COM3']
32
44
  ```
33
45
 
34
- ## PyPI Installation
46
+ ## Installation from PyPI
35
47
 
36
48
  ```bash
37
49
  python -m pip install lscom
@@ -60,5 +72,3 @@ To remove:
60
72
  ```bash
61
73
  python -m pip uninstall lscom
62
74
  ```
63
-
64
-
@@ -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: bdist_wheel (0.38.4)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,3 +1,2 @@
1
1
  [console_scripts]
2
2
  lscom = lscom.__main__:main
3
-
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
lscom/lscom.py DELETED
@@ -1,39 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- import glob
4
- import sys
5
-
6
- try:
7
- import serial # type: ignore
8
- except ModuleNotFoundError:
9
- print("required module pyserial not found... exiting...")
10
- sys.exit(-1)
11
-
12
-
13
- def list_active_serial_port_names():
14
- """Lists serial port names
15
-
16
- :raises EnvironmentError:
17
- On unsupported or unknown platforms
18
- :returns:
19
- A list of the serial ports available on the system
20
- """
21
- if sys.platform.startswith("win"):
22
- ports = ["COM%s" % (i + 1) for i in range(256)]
23
- elif sys.platform.startswith("linux") or sys.platform.startswith("cygwin"):
24
- # this excludes your current terminal "/dev/tty"
25
- ports = glob.glob("/dev/tty[A-Za-z]*")
26
- elif sys.platform.startswith("darwin"):
27
- ports = glob.glob("/dev/tty.*")
28
- else:
29
- raise EnvironmentError("Unsupported platform")
30
-
31
- result = []
32
- for port in ports:
33
- try:
34
- _serial = serial.Serial(port)
35
- _serial.close()
36
- result.append(port)
37
- except (OSError, serial.SerialException):
38
- pass
39
- return result
@@ -1,12 +0,0 @@
1
- lscom/__init__.py,sha256=WtN4T7mOGywQBrXJV6LI-LVOEO4VsVYv_IDUk_ZzWFY,68
2
- lscom/__main__.py,sha256=6RCIzGVNc9T5bHx65GvmyDBoO6JYVZmMStT2mSmwJIU,953
3
- lscom/__version__.py,sha256=xEY4OgWJuvOGR4z9UDXtGJWkxoi0oUC9nZHTx90AILM,357
4
- lscom/app.py,sha256=ssUiyLUc2lYfp87YhqjEDP0Uj22OMO9LWail6uc4cOQ,1834
5
- lscom/helpers.py,sha256=SjIaLbAOGaINW1kartBVnvkdGBGmPv6PlKdtjd9j0cQ,590
6
- lscom/lscom.py,sha256=JFO3dhyGMgqLAc36wk7rL3NjPkVc-hvYqMjNUpDUV2w,1127
7
- lscom-0.0.2.dist-info/LICENSE,sha256=sCQdvgDLxhhGvVufZs7UIRmNCbQTtxgILkaTTJhWZVY,1092
8
- lscom-0.0.2.dist-info/METADATA,sha256=EMS_uT8TQZ027zZVk-E9QAnRD8wxL6B5swhTkaQO2tI,1877
9
- lscom-0.0.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
10
- lscom-0.0.2.dist-info/entry_points.txt,sha256=6JBCsARBUs1UcpssS-LLrI7bfS67xieDcWq404aXEVU,47
11
- lscom-0.0.2.dist-info/top_level.txt,sha256=7aXJNRvNg3caDlTXuU_fLFVJD0dhaZG84UdVRUxLqcc,6
12
- lscom-0.0.2.dist-info/RECORD,,