403Webshell
Server IP : 172.67.216.182  /  Your IP : 162.158.106.108
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/serial/urlhandler/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/serial/urlhandler/protocol_alt.py
#! python
#
# This module implements a special URL handler that allows selecting an
# alternate implementation provided by some backends.
#
# This file is part of pySerial. https://github.com/pyserial/pyserial
# (C) 2015 Chris Liechti <[email protected]>
#
# SPDX-License-Identifier:    BSD-3-Clause
#
# URL format:    alt://port[?option[=value][&option[=value]]]
# options:
# - class=X used class named X instead of Serial
#
# example:
#   use poll based implementation on Posix (Linux):
#   python -m serial.tools.miniterm alt:///dev/ttyUSB0?class=PosixPollSerial

from __future__ import absolute_import

try:
    import urlparse
except ImportError:
    import urllib.parse as urlparse

import serial


def serial_class_for_url(url):
    """extract host and port from an URL string"""
    parts = urlparse.urlsplit(url)
    if parts.scheme != 'alt':
        raise serial.SerialException(
            'expected a string in the form "alt://port[?option[=value][&option[=value]]]": '
            'not starting with alt:// ({!r})'.format(parts.scheme))
    class_name = 'Serial'
    try:
        for option, values in urlparse.parse_qs(parts.query, True).items():
            if option == 'class':
                class_name = values[0]
            else:
                raise ValueError('unknown option: {!r}'.format(option))
    except ValueError as e:
        raise serial.SerialException(
            'expected a string in the form '
            '"alt://port[?option[=value][&option[=value]]]": {!r}'.format(e))
    if not hasattr(serial, class_name):
        raise ValueError('unknown class: {!r}'.format(class_name))
    cls = getattr(serial, class_name)
    if not issubclass(cls, serial.Serial):
        raise ValueError('class {!r} is not an instance of Serial'.format(class_name))
    return (''.join([parts.netloc, parts.path]), cls)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if __name__ == '__main__':
    s = serial.serial_for_url('alt:///dev/ttyS0?class=PosixPollSerial')
    print(s)

Youez - 2016 - github.com/yon3zu
LinuXploit