python类system()的实例源码

test_help_function_of_sqlite.py 文件源码 项目:PlasoScaffolder 作者: ClaudiaSaxer 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def testHelpMessageForSQLitePlugin(self):
    """test the --help option for SQLite"""
    helper = end_to_end_test_helper.EndToEndTestHelper('not needed',
                                                       'not needed')

    if platform.system() in ['Linux']:
      message_help = (
          'Usage: main.py sqlite [OPTIONS]\r\n\r\n'
          'Options:\r\n  '
          '--path TEXT       The path to plaso\r\n  '
          '--name TEXT       The plugin name\r\n  '
          '--testfile TEXT   The testfile path\r\n  '
          '--sql / --no-sql  The output example flag for the SQL Query for the '
          'plugin.\r\n  '
          '--help            Show this message and exit.')

      command = 'python {0} sqlite --help'.format(helper.MAIN_PATH)
      child = pexpect.spawn(command)
      child.expect_exact(message_help)
    else:
      raise NotImplementedError("test only implemented for linux platform")
factory.py 文件源码 项目:Stitch 作者: nathanlopez 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def mss(*args, **kwargs):
    ''' Factory returning a proper MSS class instance.

        It detects the plateform we are running on
        and choose the most adapted mss_class to take
        screenshots.

        It then proxies its arguments to the class for
        instantiation.
    '''

    operating_system = system().lower()
    if operating_system == 'darwin':
        from .darwin import MSS
    elif operating_system == 'linux':
        from .linux import MSS
    elif operating_system == 'windows':
        from .windows import MSS
    else:
        err = 'System "{0}" not implemented.'.format(operating_system)
        raise ScreenshotError(err)

    return MSS(*args, **kwargs)
tools.py 文件源码 项目:botterlord 作者: Marchearth 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_path(filename = None):
    if platform.system() == "Windows":
        separator = "\\"
    else:
        separator = "/"
    try:
        filename = filename.split('/') #For in code expressions
    except:
        pass
    _path = Path.cwd()

    if filename != None:
        for i in filename:
            if i != None:
                _path = PurePath(_path, i)
    _path = str(_path)
    return _path
markers.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def default_environment():
    if hasattr(sys, 'implementation'):
        iver = format_full_version(sys.implementation.version)
        implementation_name = sys.implementation.name
    else:
        iver = '0'
        implementation_name = ''

    return {
        "implementation_name": implementation_name,
        "implementation_version": iver,
        "os_name": os.name,
        "platform_machine": platform.machine(),
        "platform_release": platform.release(),
        "platform_system": platform.system(),
        "platform_version": platform.version(),
        "python_full_version": platform.python_version(),
        "platform_python_implementation": platform.python_implementation(),
        "python_version": platform.python_version()[:3],
        "sys_platform": sys.platform,
    }
markers.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def default_environment():
    if hasattr(sys, 'implementation'):
        iver = format_full_version(sys.implementation.version)
        implementation_name = sys.implementation.name
    else:
        iver = '0'
        implementation_name = ''

    return {
        "implementation_name": implementation_name,
        "implementation_version": iver,
        "os_name": os.name,
        "platform_machine": platform.machine(),
        "platform_release": platform.release(),
        "platform_system": platform.system(),
        "platform_version": platform.version(),
        "python_full_version": platform.python_version(),
        "platform_python_implementation": platform.python_implementation(),
        "python_version": platform.python_version()[:3],
        "sys_platform": sys.platform,
    }
appjar.py 文件源码 项目:SceneDensity 作者: ImOmid 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __addRightClickMenu(self, widget):
        widget.bind("<FocusIn>", self.__checkCopyAndPaste, add="+")
        widget.bind("<FocusOut>", self.__checkCopyAndPaste, add="+")

        if widget.var is None:  # TEXT:
            widget.bind('<KeyRelease>', self.__checkCopyAndPaste)
            widget.bind('<<Paste>>', self.__checkCopyAndPaste)

        else:
            widget.var.trace(
                "w",
                lambda name,
                index,
                mode,
                e=None,
                w=widget: self.__checkCopyAndPaste(
                    e,
                    w))  # ENTRY/OPTION

        if self.platform in [self.WINDOWS, self.LINUX]:
            widget.bind('<Button-3>', self.__rightClick)
        else:
            widget.bind('<Button-2>', self.__rightClick)
appjar.py 文件源码 项目:SceneDensity 作者: ImOmid 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __buildTextArea(self, title, frame, scrollable=False):
        self.__verifyItem(self.n_textAreas, title, True)
        if scrollable:
            text = AjScrolledText(frame)
        else:
            text = AjText(frame)
        text.config(font=self.taFont, width=20, height=10, undo=True)

        if self.platform in [self.MAC, self.LINUX]:
            text.config(highlightbackground=self.__getContainerBg())

        text.bind("<Tab>", self.__focusNextWindow)
        text.bind("<Shift-Tab>", self.__focusLastWindow)

        # add a right click menu
        text.var = None
        self.__addRightClickMenu(text)

        self.n_textAreas[title] = text
        self.logTextArea(title)

        return text

    # add external dnd support
common_methods.py 文件源码 项目:Forensic-Tools 作者: MonroCoury 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def get_firefox_db(db_file):
    '''Return the full path of firefox sqlite databases, platform independent'''
    success = False
    plat_dict = {"Windows 7" : r"C:\Users\%s\AppData\Roaming\Mozilla\Firefox\Profiles" % os.getlogin(),
                 "Windows XP" : r"C:\Documents and Settings\%s\Application Data\Mozilla\Firefox\Profiles" % os.getlogin(),
                 "Linux" : r"/home/%s/.mozilla/firefox/" % os.getlogin(),
                 "Darwin" : r"/Users/%s/Library/Application Support/Firefox/Profiles" % os.getlogin()}
    if platform.system() == "Windows":
        string = plat_dict[platform.system() + " " + platform.release()]
    else:
        string = plat_dict[platform.system()]
    for item in os.listdir(string):
        if os.path.isdir(os.path.join(string, item)) and "default" in item:
            if os.path.isfile(os.path.join(string, item, db_file)):
                success = True
                return os.path.join(string, item, db_file)
    if not success:
        sys.exit("Couldn't find the database file in the default location! Try providing a different location using the -b option...")
markers.py 文件源码 项目:my-first-blog 作者: AnkurBegining 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def default_environment():
    if hasattr(sys, 'implementation'):
        iver = format_full_version(sys.implementation.version)
        implementation_name = sys.implementation.name
    else:
        iver = '0'
        implementation_name = ''

    return {
        "implementation_name": implementation_name,
        "implementation_version": iver,
        "os_name": os.name,
        "platform_machine": platform.machine(),
        "platform_release": platform.release(),
        "platform_system": platform.system(),
        "platform_version": platform.version(),
        "python_full_version": platform.python_version(),
        "platform_python_implementation": platform.python_implementation(),
        "python_version": platform.python_version()[:3],
        "sys_platform": sys.platform,
    }
markers.py 文件源码 项目:my-first-blog 作者: AnkurBegining 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def default_environment():
    if hasattr(sys, 'implementation'):
        iver = format_full_version(sys.implementation.version)
        implementation_name = sys.implementation.name
    else:
        iver = '0'
        implementation_name = ''

    return {
        "implementation_name": implementation_name,
        "implementation_version": iver,
        "os_name": os.name,
        "platform_machine": platform.machine(),
        "platform_release": platform.release(),
        "platform_system": platform.system(),
        "platform_version": platform.version(),
        "python_full_version": platform.python_version(),
        "platform_python_implementation": platform.python_implementation(),
        "python_version": platform.python_version()[:3],
        "sys_platform": sys.platform,
    }
analytics.py 文件源码 项目:PyPlanet 作者: PyPlanet 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def capture(
        self, event_name, event_properties=None
    ):
        event_properties = event_properties or dict()
        user_properties = dict(
            path=self.instance.game.server_path,
            server_name=self.instance.game.server_name,
            language=self.instance.game.server_language,
            login=self.instance.game.server_player_login,
            title=self.instance.game.dedicated_title,
            dedicated_build=self.instance.game.dedicated_build,
            dedicated_version=self.instance.game.dedicated_version,
        )

        await self.execute(dict(
            user_id=self.instance.game.server_player_login,
            event_type=event_name, event_properties=event_properties, user_properties=user_properties,
            app_version=version, platform=platform.platform(), os_name=platform.system(), os_version=platform.version(),
            language=self.instance.game.server_language
        ))
CICSpwn.py 文件源码 项目:mainframe-attack-library 作者: wavestone-cdt 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def disable_journal():
    """
        Disables logging in CICS (except for system logs)
    """
    number_journals = 0;
    all_journals = 0;
    em.move_to(1,2)
    req_set_jour = CEMT+" S JOURNAL ALL DIS"
    em.safe_send(format_request(req_set_jour))
    em.send_enter()

    data = em.screen_get()
    for d in data:
       if "Jou(" in d and "NORMAL" in d and "Dis" in d and "DFHLOG" not in d:
           number_journals +=1;
           all_journals += 1;
       elif "Jou(" in d and "NORMAL" not in d and "Ena" in d and "DFHLOG" not in d:
           pos= d.find("Jou(") + len("Jou(")
           whine("Journal "+d[pos:pos+8]+" could not be disabled",'err')
           all_journals += 1;

    if number_journals > 0:
       whine(str(number_journals)+" of "+str(all_journals) +" journals were disabled",'good')
    else:
       whine("Only DFHLOG is defined, cannot disable this system log",'err')
test_help_function.py 文件源码 项目:PlasoScaffolder 作者: ClaudiaSaxer 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def testHelpMessage(self):
    """test the universal --help Option"""
    helper = end_to_end_test_helper.EndToEndTestHelper('not needed',
                                                       'not needed')

    if platform.system() in ['Linux']:
      message_help = ('Usage: main.py [OPTIONS] COMMAND [ARGS]...\r\n\r\n'
                      'Options:\r\n'
                      '  --help  Show this message and exit.\r\n\r\n'
                      'Commands:\r\n'
                      '  sqlite')
      command = 'python {0} --help'.format(helper.MAIN_PATH)
      child = pexpect.spawn(command)
      child.expect_exact(message_help)
    else:
      raise NotImplementedError("test only implemented for linux platform")
launcher.py 文件源码 项目:wpw-sdk-python 作者: WPTechInnovation 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def launch(self, cfg, path, flags):
        logging.debug("Determine the OS and Architecture this application is currently running on")
        hostOS = platform.system().lower()
        logging.debug("hostOS: " + str(hostOS))
        is_64bits = sys.maxsize > 2 ** 32
        if is_64bits:
            hostArchitecture = 'x64'
        else:
            hostArchitecture = 'ia32'
        logging.debug("hostArchitecture: " + str(hostArchitecture))
        if(self.validateConfig(cfg, hostOS, hostArchitecture)):
            fnull = open(os.devnull, 'w')
            if os.environ.get("WPW_HOME") is not None:
                cmd = [os.environ["WPW_HOME"] + '/bin/rpc-agent-' + platform.system().lower() + '-' + self.detectHostArchitecture()]
            else:
                cmd = [path + '/wpwithinpy/iot-core-component/bin/rpc-agent-' + platform.system().lower() + '-' + self.detectHostArchitecture()]
            cmd.extend(flags)
            proc = subprocess.Popen(cmd, stdin=None, stdout=fnull, stderr=subprocess.STDOUT)
            return proc
        else:
            logging.debug("Invalid OS/Architecture combination detected")
StartAppium.py 文件源码 项目:Auto_Analysis 作者: ztwo 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __start_driver(self, aport, bpport):
        """
        ??logcat?appium????
        :return:
        """
        if platform.system() == 'Windows':
            # ?win10??appium?bug,??????
            import subprocess
            subprocess.Popen("appium -p %s -bp %s -U %s" %
                             (aport, bpport, self.device), shell=True)

        else:
            appium = U.cmd("appium -p %s -bp %s -U %s" %
                           (aport, bpport, self.device))  # ??appium
            while True:
                appium_line = appium.stdout.readline().strip()
                U.Logging.debug(appium_line)
                U.sleep(1)
                if 'listener started' in appium_line or 'Error: listen' in appium_line:
                    break
adbUtils.py 文件源码 项目:Auto_Analysis 作者: ztwo 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_pid(self, package_name):
        """
        ????pid
        args:
        - packageName -: ????
        usage: getPid("com.android.settings")
        """
        if system is "Windows":
            pidinfo = self.shell(
                "ps | findstr %s$" %
                package_name).stdout.read()
        else:
            pidinfo = self.shell(
                "ps | %s -w %s" %
                (find_util, package_name)).stdout.read()

        if pidinfo == '':
            return "the process doesn't exist."

        pattern = re.compile(r"\d+")
        result = pidinfo.split(" ")
        result.remove(result[0])

        return pattern.findall(" ".join(result))[0]
config.py 文件源码 项目:kaira 作者: mulonemartin 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def from_object(self, obj):
        """Update the values from the given object.
        Objects are usually either modules or classes.
        Just the uppercase variables in that object are stored in the config.
        Example usage::
            from yourapplication import default_config
            app.config.from_object(default_config)
        You should not use this function to load the actual configuration but
        rather configuration defaults. The actual config should be loaded
        with :meth:`from_pyfile` and ideally from a location not within the
        package because the package might be installed system wide.
        :param obj: an object holding the configuration
        """
        for key in dir(obj):
            if key.isupper():
                self[key] = getattr(obj, key)
cindex.py 文件源码 项目:rscfl 作者: lc525 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_filename(self):
        if Config.library_file:
            return Config.library_file

        import platform
        import ctypes.util
        name = platform.system()

        if name == 'Windows':
            filename = 'libclang.dll'
        else:
            # Does the right thing on Linux and MacOS X
            filename = ctypes.util.find_library ('clang')

            # On Ubuntu, find_library fails and returns None
            # this will break loading below so replace with libclang.so
            if filename is None:
                return 'libclang.so'

        if Config.library_path:
            filename = Config.library_path + '/' + filename

        return filename
test_concurrent.py 文件源码 项目:deb-python-cassandra-driver 作者: openstack 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def validate_result_ordering(self, results):
        """
        This method will validate that the timestamps returned from the result are in order. This indicates that the
        results were returned in the order they were submitted for execution
        :param results:
        """
        last_time_added = 0
        for success, result in results:
            self.assertTrue(success)
            current_time_added = list(result)[0]

            #Windows clock granularity makes this equal most of the times
            if "Windows" in platform.system():
                self.assertLessEqual(last_time_added, current_time_added)
            else:
                self.assertLess(last_time_added, current_time_added)
            last_time_added = current_time_added
base_test.py 文件源码 项目:Projects 作者: it2school 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def not_init_assertions(self):
        self.assert_(not pygame.display.get_init(),
                     "display shouldn't be initialized" )
        if 'pygame.mixer' in sys.modules:
            self.assert_(not pygame.mixer.get_init(),
                         "mixer shouldn't be initialized" )
        if 'pygame.font' in sys.modules:
            self.assert_(not pygame.font.get_init(),
                         "init shouldn't be initialized" )

        ## !!! TODO : Remove when scrap works for OS X
        import platform
        if platform.system().startswith('Darwin'):
            return

        try:
            self.assertRaises(pygame.error, pygame.scrap.get)
        except NotImplementedError:
            # Scrap is optional.
            pass

        # pygame.cdrom
        # pygame.joystick
markers.py 文件源码 项目:pip-update-requirements 作者: alanhamlett 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def default_environment():
    if hasattr(sys, 'implementation'):
        iver = format_full_version(sys.implementation.version)
        implementation_name = sys.implementation.name
    else:
        iver = '0'
        implementation_name = ''

    return {
        "implementation_name": implementation_name,
        "implementation_version": iver,
        "os_name": os.name,
        "platform_machine": platform.machine(),
        "platform_release": platform.release(),
        "platform_system": platform.system(),
        "platform_version": platform.version(),
        "python_full_version": platform.python_version(),
        "platform_python_implementation": platform.python_implementation(),
        "python_version": platform.python_version()[:3],
        "sys_platform": sys.platform,
    }
abstract_repository.py 文件源码 项目:poco 作者: shiwaforce 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def check_remote(url):
        # TODO need a better solution
        o = urlparse.urlparse(url)
        host = o.netloc
        while "@" in host:
            host = host[host.find("@")+1:]
        while ":" in host:
            host = host[:host.find(":")]
        cmd = list()
        cmd.append("ping")
        if platform.system().lower().startswith("win"):
            cmd.append("-n")
            cmd.append("1")
            cmd.append("-w")
            cmd.append("1000")
        else:
            cmd.append("-c1")
            cmd.append("-t1")
        cmd.append(host)

        p = Popen(" ".join(cmd), stdout=PIPE, stderr=PIPE, shell=True)
        out, err = p.communicate()

        return len(err) == 0
command_handler.py 文件源码 项目:poco 作者: shiwaforce 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_environment_variables(self, plan):
        """Get all environment variables depends on selected plan"""
        envs = list()
        if isinstance(plan, dict):
            if 'environment' in plan:
                if 'include' in plan['environment']:
                    envs.extend(ProjectUtils.get_list_value(plan['environment']['include']))
            if 'docker-compose-dir' in plan:
                envs.extend(FileUtils.get_filtered_sorted_alter_from_base_dir(base_dir=self.repo_dir,
                                                                              actual_dir=self.working_directory,
                                                                              target_directories=ProjectUtils.
                                                                              get_list_value(
                                                                                  plan['docker-compose-dir']),
                                                                              filter_ends='.env'))
        env_dict = self.get_environment_dict(envs=envs)
        env_copy = os.environ.copy()
        for key in env_dict.keys():
            env_copy[key] = env_dict[key]

        """Add host system to environment"""
        env_copy["HOST_SYSTEM"] = platform.system()
        return env_copy
command_handler.py 文件源码 项目:poco 作者: shiwaforce 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_script_base(self):
        command_array = list()
        command_array.append("docker")
        command_array.append("run")

        """Add host system to environment"""
        command_array.append("-e")
        command_array.append("HOST_SYSTEM="+platform.system())
        command_array.append("-u")
        command_array.append("1000")
        command_array.append("-v")
        command_array.append(str(self.working_directory) + ":/usr/local")
        command_array.append("-w")
        command_array.append("/usr/local")
        command_array.append("alpine:latest")
        command_array.append("/bin/sh")
        command_array.append("-c")
        return command_array
speedtest.py 文件源码 项目:SmartSocks 作者: waylybaye 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def build_user_agent():
    """Build a Mozilla/5.0 compatible User-Agent string"""

    global USER_AGENT
    if USER_AGENT:
        return USER_AGENT

    ua_tuple = (
        'Mozilla/5.0',
        '(%s; U; %s; en-us)' % (platform.system(), platform.architecture()[0]),
        'Python/%s' % platform.python_version(),
        '(KHTML, like Gecko)',
        'speedtest-cli/%s' % __version__
    )
    USER_AGENT = ' '.join(ua_tuple)
    printer(USER_AGENT, debug=True)
    return USER_AGENT
service.py 文件源码 项目:vdi-broker 作者: cloudbase 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, name):
        self._host = CONF.api_listen
        self._port = CONF.api_listen_port

        if platform.system() == "Windows":
            self._workers = 1
        else:
            self._workers = (
                CONF.api_workers or processutils.get_worker_count())

        self._loader = wsgi.Loader(CONF)
        self._app = self._loader.load_app(name)

        self._server = wsgi.Server(CONF,
                                   name,
                                   self._app,
                                   host=self._host,
                                   port=self._port)
client.py 文件源码 项目:ParadoxIP150v2 作者: Tertiush 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def tls_insecure_set(self, value):
        """Configure verification of the server hostname in the server certificate.

        If value is set to true, it is impossible to guarantee that the host
        you are connecting to is not impersonating your server. This can be
        useful in initial server testing, but makes it possible for a malicious
        third party to impersonate your server through DNS spoofing, for
        example.

        Do not use this function in a real system. Setting value to true means
        there is no point using encryption.

        Must be called before connect()."""
        if HAVE_SSL is False:
            raise ValueError('This platform has no SSL/TLS.')

        self._tls_insecure = value
markers.py 文件源码 项目:swjtu-pyscraper 作者: Desgard 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def default_environment():
    if hasattr(sys, 'implementation'):
        iver = format_full_version(sys.implementation.version)
        implementation_name = sys.implementation.name
    else:
        iver = '0'
        implementation_name = ''

    return {
        "implementation_name": implementation_name,
        "implementation_version": iver,
        "os_name": os.name,
        "platform_machine": platform.machine(),
        "platform_release": platform.release(),
        "platform_system": platform.system(),
        "platform_version": platform.version(),
        "python_full_version": platform.python_version(),
        "platform_python_implementation": platform.python_implementation(),
        "python_version": platform.python_version()[:3],
        "sys_platform": sys.platform,
    }
markers.py 文件源码 项目:swjtu-pyscraper 作者: Desgard 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def default_environment():
    if hasattr(sys, 'implementation'):
        iver = format_full_version(sys.implementation.version)
        implementation_name = sys.implementation.name
    else:
        iver = '0'
        implementation_name = ''

    return {
        "implementation_name": implementation_name,
        "implementation_version": iver,
        "os_name": os.name,
        "platform_machine": platform.machine(),
        "platform_release": platform.release(),
        "platform_system": platform.system(),
        "platform_version": platform.version(),
        "python_full_version": platform.python_version(),
        "platform_python_implementation": platform.python_implementation(),
        "python_version": platform.python_version()[:3],
        "sys_platform": sys.platform,
    }
sg.py 文件源码 项目:steam_gifts_bot 作者: 4815162342lost 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def do_beep(reason):
    """do beep with PC speacker. Work only on Linux and requrement motherboard speaker"""
    if not need_beep:
        return 0
    if (datetime.datetime.now().time().hour < 9 or datetime.datetime.now().time().hour > 22) and silent_mode_at_night:
        debug_messages("Not beep, because too late")
        return 0
    if platform.system() == "Linux" or platform.system() == "FreeBSD":
        if reason == "coockie_exept":
            call(["beep", "-l 2000", "-f 1900", "-r 3"])
        elif reason == "critical":
            call(["beep", "-l 1000", "-r 10", "-f 1900"])
        elif reason == "won":
            os.system("./win.sh")
        elif reason == "bad_words":
            call(["beep", "-l 300", "-r 30", "-f 1900"])


问题


面经


文章

微信
公众号

扫码关注公众号