当前位置: 首页>>代码示例>>Python>>正文


Python Service.stop方法代码示例

本文整理汇总了Python中service.Service.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Service.stop方法的具体用法?Python Service.stop怎么用?Python Service.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在service.Service的用法示例。


在下文中一共展示了Service.stop方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: WebDriver

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class WebDriver(RemoteWebDriver):
    """
    Controls the OperaDriver and allows you to drive the browser.
    
    """

    def __init__(self, executable_path=None, port=0, desired_capabilities=DesiredCapabilities.OPERA):
        """
        Creates a new instance of the Opera driver.

        Starts the service and then creates new instance of Opera Driver.

        :Args:
         - executable_path - path to the executable. If the default is used it assumes the executable is in the
           Environment Variable SELENIUM_SERVER_JAR
         - port - port you would like the service to run, if left as 0, a free port will be found.
         - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various Opera switches).
        """
        if executable_path is None:
            try:
                executable_path = os.environ["SELENIUM_SERVER_JAR"]
            except:
                raise Exception(
                    "No executable path given, please add one to Environment Variable \
                'SELENIUM_SERVER_JAR'"
                )
        self.service = Service(executable_path, port=port)
        self.service.start()

        RemoteWebDriver.__init__(
            self, command_executor=self.service.service_url, desired_capabilities=desired_capabilities
        )

    def quit(self):
        """
        Closes the browser and shuts down the OperaDriver executable
        that is started when starting the OperaDriver
        """
        try:
            RemoteWebDriver.quit(self)
        except httplib.BadStatusLine:
            pass
        finally:
            self.service.stop()

    def save_screenshot(self, filename):
        """
        Gets the screenshot of the current window. Returns False if there is
        any IOError, else returns True. Use full paths in your filename.
        """
        png = RemoteWebDriver.execute(self, Command.SCREENSHOT)["value"]
        try:
            f = open(filename, "wb")
            f.write(base64.decodestring(png))
            f.close()
        except IOError:
            return False
        finally:
            del png
        return True
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:62,代码来源:webdriver.py

示例2: WebDriver

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class WebDriver(RemoteWebDriver):

    def __init__(self, executable_path='IEDriverServer.exe', 
                    port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT):
        self.port = port
        if self.port == 0:
            self.port = utils.free_port()

        self.iedriver = Service(executable_path, port=self.port)
        self.iedriver.start()

        RemoteWebDriver.__init__(
            self,
            command_executor='http://localhost:%d' % self.port,
            desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)

    def quit(self):
        RemoteWebDriver.quit(self)
        self.iedriver.stop()

    def save_screenshot(self, filename):
        """
        Gets the screenshot of the current window. Returns False if there is
        any IOError, else returns True. Use full paths in your filename.
        """
        png = RemoteWebDriver.execute(self, Command.SCREENSHOT)['value']
        try:
            f = open(filename, 'wb')
            f.write(base64.decodestring(png))
            f.close()
        except IOError:
            return False
        finally:
            del png
        return True
开发者ID:saucelabs,项目名称:Selenium2,代码行数:37,代码来源:webdriver.py

示例3: WebDriver

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class WebDriver(RemoteWebDriver):

    def __init__(self, executable_path='IEDriverServer.exe', 
                 port=DEFAULT_PORT, timeout=DEFAULT_TIMEOUT, host=DEFAULT_HOST,
                 log_level=DEFAULT_LOG_LEVEL, log_file=DEFAULT_LOG_FILE):
        self.port = port
        if self.port == 0:
            self.port = utils.free_port()
        self.host = host
        self.log_level = log_level
        self.log_file = log_file

        self.iedriver = Service(executable_path, port=self.port,
             host=self.host, log_level=self.log_level, log_file=self.log_file)

        self.iedriver.start()

        RemoteWebDriver.__init__(
            self,
            command_executor='http://localhost:%d' % self.port,
            desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)

    def quit(self):
        RemoteWebDriver.quit(self)
        self.iedriver.stop()
开发者ID:krosenvold,项目名称:selenium-git-release-candidate,代码行数:27,代码来源:webdriver.py

示例4: Opera

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class Opera(RemoteWebDriver):

    def __init__(self):
        self.service = Service(logging_level, port)
        self.service.start()
        RemoteWebDriver.__init__(self,
            command_executor=self.service.service_url,
            desired_capabilities=DesiredCapabilities.OPERA)

    def quit(self):
        """ Closes the browser and shuts down the ChromeDriver executable
            that is started when starting the ChromeDriver """
        try:
            RemoteWebDriver.quit(self)
        except httplib.BadStatusLine:
            pass
        finally:
            self.service.stop()

    def save_screenshot(self, filename):
        """
        Gets the screenshot of the current window. Returns False if there is
        any IOError, else returns True. Use full paths in your filename.
        """
        png = self._execute(Command.SCREENSHOT)['value']
        try:
            f = open(filename, 'wb')
            f.write(base64.decodestring(png))
            f.close()
        except IOError:
            return False
        finally:
            del png
        return True
开发者ID:hali4ka,项目名称:robotframework-selenium2library,代码行数:36,代码来源:webdriver.py

示例5: WebDriver

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class WebDriver(RemoteWebDriver):
    """
    Controls the ChromeDriver and allows you to drive the browser.

    You will need to download the ChromeDriver executable from
    http://code.google.com/p/chromedriver/downloads/list
    """

    def __init__(self, executable_path="chromedriver", port=0,
                 chrome_options=None, service_args=None,
                 desired_capabilities=None, service_log_path=None):
        """
        Creates a new instance of the chrome driver.

        Starts the service and then creates new instance of chrome driver.

        :Args:
         - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
         - port - port you would like the service to run, if left as 0, a free port will be found.
         - desired_capabilities: Dictionary object with non-browser specific
           capabilities only, such as "proxy" or "loggingPref".
         - chrome_options: this takes an instance of ChromeOptions
        """
        if chrome_options is None:
            options = Options()
        else:
            options = chrome_options

        if desired_capabilities is not None:
          desired_capabilities.update(options.to_capabilities())
        else:
          desired_capabilities = options.to_capabilities()

        self.service = Service(executable_path, port=port,
            service_args=service_args, log_path=service_log_path)
        self.service.start()

        try:
            RemoteWebDriver.__init__(self,
                command_executor=self.service.service_url,
                desired_capabilities=desired_capabilities)
        except:
            self.quit()
            raise
        self._is_remote = False

    def quit(self):
        """
        Closes the browser and shuts down the ChromeDriver executable
        that is started when starting the ChromeDriver
        """
        try:
            RemoteWebDriver.quit(self)
        except:
            # We don't care about the message because something probably has gone wrong
            pass
        finally:
            self.service.stop()
开发者ID:craigds,项目名称:selenium,代码行数:60,代码来源:webdriver.py

示例6: WebDriver

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class WebDriver(RemoteWebDriver):
    """
    Wrapper to communicate with PhantomJS through Ghostdriver.

    You will need to follow all the directions here:
    https://github.com/detro/ghostdriver
    """

    def __init__(self, executable_path="phantomjs",
                 port=0, desired_capabilities=DesiredCapabilities.PHANTOMJS,
                 service_args=None, service_log_path=None):
        """
        Creates a new instance of the PhantomJS / Ghostdriver.

        Starts the service and then creates new instance of the driver.

        :Args:
         - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
         - port - port you would like the service to run, if left as 0, a free port will be found.
         - desired_capabilities: Dictionary object with non-browser specific
           capabilities only, such as "proxy" or "loggingPref".
         - service_args : A List of command line arguments to pass to PhantomJS
         - service_log_path: Path for phantomjs service to log to.
        """
        self.service = Service(executable_path, port=port,
            service_args=service_args, log_path=service_log_path)
        self.service.start()

        try:
            RemoteWebDriver.__init__(self,
                command_executor=self.service.service_url,
                desired_capabilities=desired_capabilities)
        except:
            self.quit()
            raise

        self._is_remote = False

    def quit(self):
        """
        Closes the browser and shuts down the PhantomJS executable
        that is started when starting the PhantomJS
        """
        try:
            RemoteWebDriver.quit(self)
        except:
            # We don't care about the message because something probably has gone wrong
            pass
        self.service.stop()

    def __del__(self):
        try:
            self.service.stop()
        except:
            pass
开发者ID:delib,项目名称:selenium,代码行数:57,代码来源:webdriver.py

示例7: WebDriver

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class WebDriver(RemoteWebDriver):
    """
    Controls the ChromeDriver and allows you to drive the browser.
    
    You will need to download the ChromeDriver executable from
    http://code.google.com/p/selenium/downloads/list
    """

    def __init__(self, executable_path="chromedriver", port=0,
                 desired_capabilities=DesiredCapabilities.CHROME):
        """
        Creates a new instance of the chrome driver.

        Starts the service and then creates new instance of chrome driver.

        :Args:
         - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
         - port - port you would like the service to run, if left as 0, a free port will be found.
         - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various chrome switches).
        """
        self.service = Service(executable_path, port=port)
        self.service.start()

        RemoteWebDriver.__init__(self,
            command_executor=self.service.service_url,
            desired_capabilities=desired_capabilities)

    def quit(self):
        """
        Closes the browser and shuts down the ChromeDriver executable
        that is started when starting the ChromeDriver
        """
        try:
            RemoteWebDriver.quit(self)
        except httplib.BadStatusLine:
            pass
        finally:
            self.service.stop()

    def save_screenshot(self, filename):
        """
        Gets the screenshot of the current window. Returns False if there is
        any IOError, else returns True. Use full paths in your filename.
        """
        png = RemoteWebDriver.execute(self, Command.SCREENSHOT)['value']
        try:
            f = open(filename, 'wb')
            f.write(base64.decodestring(png))
            f.close()
        except IOError:
            return False
        finally:
            del png
        return True
开发者ID:hhakkala,项目名称:robotframework-selenium2library-boilerplate,代码行数:56,代码来源:webdriver.py

示例8: WebDriver

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class WebDriver(RemoteWebDriver):

    def __init__(self,deviceID=None,port=0):
        self.service = Service(deviceID,port=port)
        self.service.start()
        RemoteWebDriver.__init__(self,
            command_executor=self.service.service_url,
            desired_capabilities=DesiredCapabilities.ANDROID)

    def quit(self):
        """ Close AndroidDriver application on device"""
        try:
            RemoteWebDriver.quit(self)
        except httplib.BadStatusLine:
            pass
        finally:
            self.service.stop()
开发者ID:Scar123,项目名称:AndroidWebDriver4Python,代码行数:19,代码来源:webdriver.py

示例9: WebDriver

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class WebDriver(RemoteWebDriver):
    """
    Controls the OperaDriver and allows you to drive the browser.
    
    """

    def __init__(self, executable_path=None, port=0,
                 desired_capabilities=DesiredCapabilities.OPERA):
        """
        Creates a new instance of the Opera driver.

        Starts the service and then creates new instance of Opera Driver.

        :Args:
         - executable_path - path to the executable. If the default is used it assumes the executable is in the
           Environment Variable SELENIUM_SERVER_JAR
         - port - port you would like the service to run, if left as 0, a free port will be found.
         - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various Opera switches).
        """
        if executable_path is None:
            try:
                executable_path = os.environ["SELENIUM_SERVER_JAR"]
            except:
                raise Exception("No executable path given, please add one to Environment Variable \
                'SELENIUM_SERVER_JAR'")
        self.service = Service(executable_path, port=port)
        self.service.start()

        RemoteWebDriver.__init__(self,
            command_executor=self.service.service_url,
            desired_capabilities=desired_capabilities)
        self._is_remote = False

    def quit(self):
        """
        Closes the browser and shuts down the OperaDriver executable
        that is started when starting the OperaDriver
        """
        try:
            RemoteWebDriver.quit(self)
        except httplib.BadStatusLine:
            pass
        finally:
            self.service.stop()
开发者ID:151706061,项目名称:X,代码行数:46,代码来源:webdriver.py

示例10: Localize

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
form = cgi.FieldStorage()
req = {
    'refresh':"0", 'service_action':"none" ,'y_scroll':"0", 'lang':"en", 'tab_id' : "-99", 'host': "localhost"
}
for key in req.keys():
    if form.has_key(key):
        req[key] = form[key].value

loc = Localize(req['lang'])
if loc.message:
    message = loc.message

### service ####
service = Service("snort", req['host'])
if req["service_action"] == "stop":
    message += service.stop()
if req["service_action"] == "start":
    message += service.start()
if req["service_action"] == "reload":
    message += service.reload()

### render html #####

### <html><head>--</head> ####
renderHead(loc.str('menu_snort'), "", "")

print("<body onLoad='setRefreshTimerAndScroll(" + req["refresh"] + "," + req["y_scroll"] + ")'>")

Menu(req['tab_id'], loc).render()

### form (hidden params) #####
开发者ID:ryobot,项目名称:misctl,代码行数:33,代码来源:snort_ctl.py

示例11: WebDriver

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class WebDriver(RemoteWebDriver):
    """
    Controls the ChromeDriver and allows you to drive the browser.
    
    You will need to download the ChromeDriver executable from
    http://code.google.com/p/chromedriver/downloads/list
    """

    def __init__(self, executable_path="chromedriver", port=0,
                 desired_capabilities=None, chrome_options=None):
        """
        Creates a new instance of the chrome driver.

        Starts the service and then creates new instance of chrome driver.

        :Args:
         - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
         - port - port you would like the service to run, if left as 0, a free port will be found.
         - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various chrome
           switches). This is being deprecated, please use chrome_options
         - chrome_options: this takes an instance of ChromeOptions
        """
        if chrome_options is None:
            options = Options()
        else:
            options = chrome_options

        if desired_capabilities is not None:
            warnings.warn("Desired Capabilities has been deprecated, please user chrome_options.", DeprecationWarning)
            desired_capabilities.update(options.to_capabilities())
        else:
            desired_capabilities = options.to_capabilities()

        self.service = Service(executable_path, port=port)
        self.service.start()

        try:
            RemoteWebDriver.__init__(self,
                command_executor=self.service.service_url,
                desired_capabilities=desired_capabilities)
        except:
            self.quit()
            raise WebDriverException("The Driver was not able to start.")

    def quit(self):
        """
        Closes the browser and shuts down the ChromeDriver executable
        that is started when starting the ChromeDriver
        """
        try:
            RemoteWebDriver.quit(self)
        except httplib.BadStatusLine:
            pass
        finally:
            self.service.stop()

    def save_screenshot(self, filename):
        """
        Gets the screenshot of the current window. Returns False if there is
        any IOError, else returns True. Use full paths in your filename.
        """
        png = RemoteWebDriver.execute(self, Command.SCREENSHOT)['value']
        try:
            f = open(filename, 'wb')
            f.write(base64.decodestring(png))
            f.close()
        except IOError:
            return False
        finally:
            del png
        return True
开发者ID:andersroos,项目名称:selenium-chat-example,代码行数:73,代码来源:webdriver.py

示例12: main

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
def main(queue_results, queue_errors):
    log.info("Starting with process ID %d", os.getpid())

    # Check if the user is an Administrator.
    # If not, quit with an error message.
    if not shell.IsUserAnAdmin():
        log.error("The user is not an Administrator, aborting")
        queue_errors.put('NOT_AN_ADMIN')
        return

    # Generate configuration values.
    cfg = Config()

    # Check if this is a supported version of Windows and if so, obtain the
    # volatility profile name.
    cfg.get_profile_name()
    if not cfg.profile:
        log.error("Unsupported version of Windows, can't select a profile")
        queue_errors.put('UNSUPPORTED_WINDOWS')
        return

    log.info("Selected Profile Name: {0}".format(cfg.profile))

    # Obtain the path to the driver to load. At this point, this check should
    # not fail, but you never know.
    if not cfg.get_driver_path():
        log.error("Unable to find a proper winpmem driver")
        queue_errors.put('NO_DRIVER')
        return

    log.info("Selected Driver: {0}".format(cfg.driver))

    # This is the ugliest black magic ever, but somehow helps.
    # Just tries to brutally destroy the winpmem service if there is one
    # lying around before trying to launch a new one again.
    destroyer = threading.Thread(target=destroy, args=(cfg.driver, cfg.service_name))
    destroyer.start()
    destroyer.join()

    # Initialize the winpmem service.
    try:
        service = Service(driver=cfg.driver, service=cfg.service_name)
        service.create()
        service.start()
    except DetectorError as e:
        log.critical("Unable to start winpmem service: %s", e)
        queue_errors.put('SERVICE_NO_START')
        return
    else:
        log.info("Service started")

    # Launch the scanner.
    try:
        scan(cfg.service_path, cfg.profile, queue_results)
    except DetectorError as e:
        log.critical("Yara scanning failed: %s", e)
        queue_errors.put('SCAN_FAILED')
    else:
        log.info("Scanning finished")

    # Stop the winpmem service and unload the driver. At this point we should
    # have cleaned up everything left on the system.
    try:
        service.stop()
        service.delete()
    except DetectorError as e:
        log.error("Unable to stop winpmem service: %s", e)
    else:
        log.info("Service stopped")

    log.info("Analysis finished")
开发者ID:RoeeM,项目名称:detekt,代码行数:73,代码来源:detector.py

示例13: SigmaWeb

# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import stop [as 别名]
class SigmaWeb():
    userConfig = None
    service = None
    kivyApp = None
    GUI = None
    
    def __init__(self):
        #Inicia o app carregando os objetos que vai precisar
        self.GUI = GUI('res/screens.kv')
        self.service = Service()
        self.kivyApp = KivyApp()
        
        #Configura o objeto do kivy e inicia o programa (isso vai chamar o on_start())
        self.kivyApp.root = self.GUI.root
        self.kivyApp.use_kivy_settings = False
        self.kivyApp.parent = self
        self.kivyApp.run()
    
    '''
    ''   KIVY CALLBACKS
    '''
    
    '''
    Chamada no momento que o usuario abre o app
    '''
    def on_start(self):
        Debug().note("on_start()")
        '''
        Faz algumas correcoes no arquivo de configuracao se a versao anterior era mais antiga que a atual
        '''
        if ProgramVersionGreater(__version__, self.userConfig.getConfig('app_version')): 
            Debug().warn("Deletando configuracoes de versao antiga!")
            username = self.userConfig.getConfig('username')
            password = self.userConfig.getConfig('password')
            self.userConfig.clearConfig()
            self.userConfig.setConfig('username', username)
            self.userConfig.setConfig('password', password)
            if self.userConfig.getConfig('username') != '': self.userConfig.setConfig('update_login', '1')
        self.userConfig.setConfig('app_delete', '0')
        
        '''
        Verifica se o usuario ja realizou o login
        '''
        if self.userConfig.getConfig('username') == '':
            self._clearConfig()
            self.GUI.setWindow(screenLogin)
        else:
            if self.userConfig.getConfig('update_login') == '0':
                self.service.start(self.userConfig.exportConfig(), (self.userConfig.getConfig('update_auto')=='0'))
                self.GUI.setProperty("msg_loading", "Carregando notas... Aguarde!")
            else:
                self.service.start(self.userConfig.exportConfig(), False)
                self.GUI.setProperty("msg_loading", "[b]Buscando notas no sistema[/b]\n\nDependendo da carga no servidor\nisto pode demorar")
            if self.GUI.getWindow() == 'NoneType': self.GUI.setWindow(screenLoading)
    
    def on_stop(self):
        Debug().note("on_stop()")
        self.userConfig.write()
        if (self.userConfig.getConfig('debug_forceexit')=='1'): Debug().warn("debug_forceexit = 1")
        self.service.stop(((self.userConfig.getConfig('update_auto')=='0') or (self.userConfig.getConfig('app_delete')=='1') or (self.userConfig.getConfig('debug_forceexit')=='1')))
        Debug().note("Aplicativo foi finalizado com sucesso!")
    
    def on_pause(self):
        Debug().note("on_pause()")
        if self.userConfig.getConfig('debug_disablepause')=='0':
            self.userConfig.write()
            self.service.stop((self.userConfig.getConfig('update_auto')=='0' and self.userConfig.getConfig('update_login') == '0'))
            Debug().note("Aplicativo foi pausado com sucesso!")
            return True
        else: return False
    
    def on_resume(self):
        Debug().note("on_resume()")
        self.on_start()
    
    def on_update(self, *args):
        keys = self.service.getKeys()
        if keys is not None:
            for keypair in keys:
                key, value = keypair
                self.userConfig.setConfig(key, value)
                
                '''
                Mensagens que o service manda para avisa o usuario de algum acontecimento
                '''
                if key == 'update_msg':
                    '''
                    Erro no servidor (durante login). Faz logoff do usuario e mostra uma mensagem na tela de login
                    '''
                    if (self.userConfig.getConfig('update_login') == '1') and (value[:46] == '[color=ff0000][b]Erro no servidor![/b][/color]'):
                        self.service.stop()
                        self._clearConfig()
                        self.GUI.setProperty('msg_error', 'Erro ao acessar o sistema. \nTente novamente mais tarde')
                        self.GUI.setWindow(screenLogin)
                    else:
                        #Mensagem nao eh um erro entao mostra ela com a cor normal
                        self.GUI.setProperty('usermsg', value)
                
                #Dados que o service baixou do usuario
                elif (key == 'update_data'):
#.........这里部分代码省略.........
开发者ID:mscansian,项目名称:SigmaWebPlus,代码行数:103,代码来源:main.py


注:本文中的service.Service.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。