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


Python service.Service类代码示例

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


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

示例1: Opera

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,代码行数:34,代码来源:webdriver.py

示例2: test_bad_random

	def test_bad_random(self, randintMock, mockOpen):
		# integers
		mockOpen.return_value = MockFile([1, 4, 7])
		randintMock.return_value = 2
		assert Service.bad_random() == 2
		randintMock.assert_called_once_with(0, 2)
		randintMock.reset_mock()
		
		# empty
		mockOpen.return_value = MockFile([])
		randintMock.return_value = -1
		assert Service.bad_random() == -1
		randintMock.assert_called_once_with(0, -1)
		randintMock.reset_mock()
		
		# float
		mockOpen.return_value = MockFile([5.2])
		randintMock.return_value = 0
		assert Service.bad_random() == 0
		randintMock.assert_called_once_with(0, 0)
		randintMock.reset_mock()
		
		# non-numeric values
		mockOpen.return_value = MockFile([1, "a", 7])
		self.assertRaises(ValueError, Service.bad_random)
		mockOpen.reset_mock()
开发者ID:cmput401-fall2018,项目名称:web-app-ci-cd-with-travis-ci-amalik2,代码行数:26,代码来源:test_service.py

示例3: test_abs_plus

def test_abs_plus():
    serviceTest = Service()
    testValue = serviceTest.abs_plus(-5)
    assert(testValue == 6)

    testValue = serviceTest.abs_plus(0)
    assert(testValue == 1)
开发者ID:cmput401-fall2018,项目名称:web-app-ci-cd-with-travis-ci-htruong1,代码行数:7,代码来源:test_service.py

示例4: get_message_by_username

def get_message_by_username(username):
    try:
        svc = Service()
        svc_response = svc.get_message_by_username(username)
        return SvcUtils.handle_response(svc_response, status.HTTP_200_OK)
    except Exception as ex:
        return SvcError.handle_error(ex)
开发者ID:EnzoGunn,项目名称:message_service,代码行数:7,代码来源:controller.py

示例5: save_message

def save_message():
    try:
        svc = Service()
        svc_response = svc.save_message(request.data)
        return SvcUtils.handle_response(svc_response, status.HTTP_201_CREATED)
    except Exception as ex:
        return SvcError.handle_error(ex)
开发者ID:EnzoGunn,项目名称:message_service,代码行数:7,代码来源:controller.py

示例6: index

 def index(self):
     platform_id = int(self.get_argument('platform_id',6))
     run_id = int(self.get_argument('run_id',0))
     plan_id = int(self.get_argument('plan_id',0))
     partner_id = int(self.get_argument('partner_id',0))
     version_name = self.get_argument('version_name','').replace('__','.')
     product_name = self.get_argument('product_name','')
     #perm
     run_list=self.run_list()
     run_list = self.filter_run_id_perms(run_list=run_list)
     run_id_list = [run['run_id'] for run in run_list]      
     if run_id == 0 and run_id_list: # has perm and doesn't select a run_id
         if len(run_id_list) == len(Run.mgr().Q().extra("status<>'hide'").data()):
             run_id = 0  # user has all run_id perms
         else:
             run_id = run_id_list[0]
     if run_id not in run_id_list and run_id != 0: # don't has perm and selete a run_id
         scope = None
     # scope 
     else:
         scope = Scope.mgr().Q().filter(platform_id=platform_id,run_id=run_id,plan_id=plan_id,
                   partner_id=partner_id,version_name=version_name,product_name=product_name)[0]
     tody = self.get_date()
     yest = tody - datetime.timedelta(days=1)
     last = yest - datetime.timedelta(days=1)
     start = tody - datetime.timedelta(days=30)
     basics,topn_sch,topn_hw,b_books,c_books = [],[],[],[],[]
     visit_y = dict([(i,{'pv':0,'uv':0}) for i in PAGE_TYPE])
     visit_l = dict([(i,{'pv':0,'uv':0}) for i in PAGE_TYPE])
     if scope:
         # basic stat
         dft = dict([(i,0) for i in BasicStatv3._fields])
         basic_y = BasicStatv3.mgr().Q(time=yest).filter(scope_id=scope.id,mode='day',time=yest)[0] 
         basic_l = BasicStatv3.mgr().Q(time=last).filter(scope_id=scope.id,mode='day',time=last)[0] 
         basic_m = BasicStatv3.mgr().get_data(scope.id,'day',start,tody,ismean=True)
         basic_p = BasicStatv3.mgr().get_peak(scope.id,'day',start,tody)
         basic_y,basic_l = basic_y or dft,basic_l or dft
         basic_y['title'],basic_l['title'] = '昨日统计','前日统计'
         basic_m['title'],basic_p['title'] = '每日平均','历史峰值'
         basics = [basic_y,basic_l,basic_m,basic_p]
         # page visit
         for i in VisitStat.mgr().Q().filter(scope_id=scope.id,mode='day',time=yest):
             visit_y[i['type']] = i
         for i in VisitStat.mgr().Q().filter(scope_id=scope.id,mode='day',time=last):
             visit_l[i['type']] = i
         # topN search & hotword
         q = TopNStat.mgr().Q().filter(scope_id=scope.id,mode='day',time=yest)
         topn_sch = q.filter(type='search').orderby('no')[:10]
         topn_hw = q.filter(type='hotword').orderby('no')[:10]
         # books of by-book & by-chapter
         q = BookStat.mgr().Q(time=yest).filter(scope_id=scope.id,mode='day',time=yest)
         b_books = Service.inst().fill_book_info(q.filter(charge_type='book').orderby('fee','DESC')[:10])
         c_books = Service.inst().fill_book_info(q.filter(charge_type='chapter').orderby('fee','DESC')[:10])
     self.render('data/basic.html',
                 platform_id=platform_id,run_id=run_id,plan_id=plan_id,
                 partner_id=partner_id,version_name=version_name,product_name=product_name,
                 run_list=self.run_list(),plan_list=self.plan_list(),date=tody.strftime('%Y-%m-%d'),
                 basics = basics,visit_y=visit_y,visit_l=visit_l,topn_sch = topn_sch,
                 topn_hw=topn_hw,b_books=b_books,c_books=c_books
                 )
开发者ID:appleface2050,项目名称:yuezhang_logstat,代码行数:60,代码来源:basic.py

示例7: process_event

def process_event():
    try:
        svc = Service()
        svc.process_event(request.data)
        return SvcUtils.handle_response(status.HTTP_200_OK)
    except Exception as ex:
        return SvcError.handle_error(ex)
开发者ID:EnzoGunn,项目名称:CheckPoint,代码行数:7,代码来源:controller.py

示例8: test_complicated_function

 def test_complicated_function(self):
     ser = Service()
     ser.bad_random = mock.Mock(return_value=15)
     re = ser.complicated_function(3)
     assert re == (5, 1)
     ser.bad_random = mock.Mock(return_value=15)
     self.assertRaises(ZeroDivisionError, ser.complicated_function,0)      
开发者ID:cmput401-fall2018,项目名称:web-app-ci-cd-with-travis-ci-Katzesama,代码行数:7,代码来源:test_service.py

示例9: test_abs_plus

def test_abs_plus():
	newService = Service()

	assert newService.abs_plus(-10) == (abs(-10) + 1)
	assert newService.abs_plus(10) == (abs(10) + 1)
	assert newService.abs_plus(0) == (abs(0) + 1)
	assert newService.abs_plus(3.14) == (abs(3.14) + 1)
开发者ID:cmput401-fall2018,项目名称:web-app-ci-cd-with-travis-ci-shardul-shah,代码行数:7,代码来源:test_service.py

示例10: strict_up

 def strict_up(self, ignore):
     started_list = []
     for i in range(len(self.services) - 1):
         for service in self.services[i]:
             try:
                 service.run()
             except AlaudaServerError as ex:
                 if str(ex).find('App {} already exists'.format(service.name)) > -1 and ignore:
                     continue
                 else:
                     print 'error: {}'.format(ex.message)
                     raise ex
         started_list.extend(self.services[i])
         ret = self._wait_services_ready(self.services[i])
         if ret is not None:
             for service in started_list:
                 Service.remove(service.name)
             raise AlaudaServerError(500, ret)
     for service in self.services[len(self.services) - 1]:
         try:
             service.run()
         except AlaudaServerError as ex:
             if str(ex).find('App {} already exists'.format(service.name)) > -1 and ignore:
                 print 'Ignore exist service -> {}'.format(service.name)
                 continue
             else:
                 raise ex
开发者ID:jianghaishanyue,项目名称:alauda-CLI,代码行数:27,代码来源:project.py

示例11: service_create

def service_create(image, name, start, target_num_instances, instance_size, run_command, env, ports, exposes,
                   volumes, links, namespace, scaling_info, custom_domain_name, region_name):
    image_name, image_tag = util.parse_image_name_tag(image)
    instance_ports, port_list = util.parse_instance_ports(ports)
    expose_list = util.merge_internal_external_ports(port_list, exposes)
    instance_ports.extend(expose_list)
    instance_envvars = util.parse_envvars(env)
    links = util.parse_links(links)
    volumes = util.parse_volumes(volumes)
    scaling_mode, scaling_cfg = util.parse_autoscale_info(scaling_info)
    if scaling_mode is None:
        scaling_mode = 'MANUAL'
    service = Service(name=name,
                      image_name=image_name,
                      image_tag=image_tag,
                      target_num_instances=target_num_instances,
                      instance_size=instance_size,
                      run_command=run_command,
                      instance_ports=instance_ports,
                      instance_envvars=instance_envvars,
                      volumes=volumes,
                      links=links,
                      namespace=namespace,
                      scaling_mode=scaling_mode,
                      autoscaling_config=scaling_cfg,
                      custom_domain_name=custom_domain_name,
                      region_name=region_name)
    if start:
        service.run()
    else:
        service.create()
开发者ID:letiantian,项目名称:alauda-CLI,代码行数:31,代码来源:commands.py

示例12: WebDriver

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,代码行数:60,代码来源:webdriver.py

示例13: WebDriver

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,代码行数:35,代码来源:webdriver.py

示例14: ping

def ping():
    try:
        svc = Service()
        svc_response = svc.ping()
        return SvcUtils.handle_response(svc_response, status.HTTP_200_OK)
    except Exception as ex:
        return SvcError.handle_error(ex)
开发者ID:EnzoGunn,项目名称:message_service,代码行数:7,代码来源:controller.py

示例15: request

    def request(self, uri):
        """Build the request to run against drupal

        request(project uri)

        Values and structure returned:
        {username: {uid:int, 
                    repo_id:int, 
                    access:boolean, 
                    branch_create:boolean, 
                    branch_update:boolean, 
                    branch_delete:boolean, 
                    tag_create:boolean,
                    tag_update:boolean,
                    tag_delete:boolean,
                    per_label:list,
                    name:str,
                    pass:md5,
                    ssh_keys: { key_name:fingerprint }
                   }
        }"""
        service = Service(AuthProtocol('vcs-auth-data'))
        service.request_json({"project_uri":self.projectname(uri)})
        def NoDataHandler(fail):
            fail.trap(ConchError)
            message = fail.value.value
            log.err(message)
            # Return a stub auth_service object
            return {"users":{}, "repo_id":None}
        service.addErrback(NoDataHandler)
        return service.deferred
开发者ID:nguyennamtien,项目名称:Drupal.org-Git-Daemons,代码行数:31,代码来源:drupalGitSSHDaemon.py


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