Linux sh52.ich-4.com 5.14.0-611.26.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 29 05:24:47 EST 2026 x86_64
LiteSpeed
Server IP : 198.143.147.58 & Your IP : 216.73.217.21
Domains :
Cant Read [ /etc/named.conf ]
User : actualbuzz
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
lib /
python3.9 /
site-packages /
serial /
tools /
Delete
Unzip
Name
Size
Permission
Date
Action
__pycache__
[ DIR ]
drwxr-xr-x
2026-02-03 14:58
__init__.py
0
B
-rw-r--r--
2015-08-02 22:00
hexlify_codec.py
3.55
KB
-rw-r--r--
2016-06-08 04:05
list_ports.py
3.27
KB
-rw-r--r--
2017-03-16 22:53
list_ports_common.py
3.24
KB
-rw-r--r--
2017-05-24 01:23
list_ports_linux.py
4.32
KB
-rw-r--r--
2017-05-24 01:23
list_ports_osx.py
9.08
KB
-rw-r--r--
2017-03-16 23:01
list_ports_posix.py
4.39
KB
-rw-r--r--
2017-03-16 22:59
list_ports_windows.py
11.07
KB
-rw-r--r--
2017-05-24 01:34
miniterm.py
34.28
KB
-rw-r--r--
2017-07-19 20:57
Save
Rename
#!/usr/bin/env python # # This is a helper module for the various platform dependent list_port # implementations. # # This file is part of pySerial. https://github.com/pyserial/pyserial # (C) 2015 Chris Liechti <cliechti@gmx.net> # # SPDX-License-Identifier: BSD-3-Clause import re import glob import os def numsplit(text): """\ Convert string into a list of texts and numbers in order to support a natural sorting. """ result = [] for group in re.split(r'(\d+)', text): if group: try: group = int(group) except ValueError: pass result.append(group) return result class ListPortInfo(object): """Info collection base class for serial ports""" def __init__(self, device=None): self.device = device self.name = None self.description = 'n/a' self.hwid = 'n/a' # USB specific data self.vid = None self.pid = None self.serial_number = None self.location = None self.manufacturer = None self.product = None self.interface = None # special handling for links if device is not None and os.path.islink(device): self.hwid = 'LINK={}'.format(os.path.realpath(device)) def usb_description(self): """return a short string to name the port based on USB info""" if self.interface is not None: return '{} - {}'.format(self.product, self.interface) elif self.product is not None: return self.product else: return self.name def usb_info(self): """return a string with USB related information about device""" return 'USB VID:PID={:04X}:{:04X}{}{}'.format( self.vid or 0, self.pid or 0, ' SER={}'.format(self.serial_number) if self.serial_number is not None else '', ' LOCATION={}'.format(self.location) if self.location is not None else '') def apply_usb_info(self): """update description and hwid from USB data""" self.description = self.usb_description() self.hwid = self.usb_info() def __eq__(self, other): return self.device == other.device def __lt__(self, other): return numsplit(self.device) < numsplit(other.device) def __str__(self): return '{} - {}'.format(self.device, self.description) def __getitem__(self, index): """Item access: backwards compatible -> (port, desc, hwid)""" if index == 0: return self.device elif index == 1: return self.description elif index == 2: return self.hwid else: raise IndexError('{} > 2'.format(index)) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - def list_links(devices): """\ search all /dev devices and look for symlinks to known ports already listed in devices. """ links = [] for device in glob.glob('/dev/*'): if os.path.islink(device) and os.path.realpath(device) in devices: links.append(device) return links # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # test if __name__ == '__main__': print(ListPortInfo('dummy'))