當前位置: 首頁>>代碼示例>>Python>>正文


Python Proxy.getUserName方法代碼示例

本文整理匯總了Python中WMCore.Credential.Proxy.Proxy.getUserName方法的典型用法代碼示例。如果您正苦於以下問題:Python Proxy.getUserName方法的具體用法?Python Proxy.getUserName怎麽用?Python Proxy.getUserName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WMCore.Credential.Proxy.Proxy的用法示例。


在下文中一共展示了Proxy.getUserName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __call__

# 需要導入模塊: from WMCore.Credential.Proxy import Proxy [as 別名]
# 或者: from WMCore.Credential.Proxy.Proxy import getUserName [as 別名]
    def __call__(self):
        server = HTTPRequests(self.serverurl, self.proxyfilename)

        self.logger.debug("Looking up detailed status of task %s" % self.cachedinfo["RequestName"])
        dictresult, status, reason = server.get(self.uri, data={"workflow": self.cachedinfo["RequestName"]})
        dictresult = dictresult["result"][0]  # take just the significant part

        if status != 200:
            msg = "Problem retrieving status:\ninput:%s\noutput:%s\nreason:%s" % (
                str(self.cachedinfo["RequestName"]),
                str(dictresult),
                str(reason),
            )
            raise RESTCommunicationException(msg)

        self.logger.debug(dictresult)  # should be something like {u'result': [[123, u'ciao'], [456, u'ciao']]}

        self.logger.info("Task name:\t\t\t%s" % self.cachedinfo["RequestName"])
        self.logger.info("Task status:\t\t\t%s" % dictresult["status"])

        # Print the url of the panda monitor
        if dictresult["taskFailureMsg"]:
            self.logger.error(
                "%sError during task injection:%s\t%s" % (colors.RED, colors.NORMAL, dictresult["taskFailureMsg"])
            )
        elif dictresult["jobSetID"]:
            p = Proxy({"logger": self.logger})
            username = urllib.quote(p.getUserName())
            self.logger.info(
                "Panda url:\t\t\thttp://panda.cern.ch/server/pandamon/query?job=*&jobsetID=%s&user=%s"
                % (dictresult["jobSetID"], username)
            )

        if dictresult["jobdefErrors"]:
            self.logger.error(
                "%sSubmission partially failed:%s\t%s jobgroup not submittet out of %s:"
                % (colors.RED, colors.NORMAL, dictresult["failedJobdefs"], dictresult["totalJobdefs"])
            )
            for error in dictresult["jobdefErrors"]:
                self.logger.info("\t%s" % error)

        # Print information about jobs
        states = dictresult["jobsPerStatus"]
        total = sum(states[st] for st in states)
        frmt = ""
        for status in states:
            frmt += status + " %s\t" % self._percentageString(states[status], total)
        if frmt:
            self.logger.info("Details:\t\t\t%s" % frmt)
開發者ID:bbockelm,項目名稱:CRABClient,代碼行數:51,代碼來源:status.py

示例2: ProxyTest

# 需要導入模塊: from WMCore.Credential.Proxy import Proxy [as 別名]
# 或者: from WMCore.Credential.Proxy.Proxy import getUserName [as 別名]

#.........這裏部分代碼省略.........
        Test if the renew method renews correctly the user proxy.
        """
        time.sleep(70)
        self.proxy.renew()
        time.sleep(10)
        timeLeft = self.proxy.getTimeLeft()
        self.assertEqual(int(timeLeft) / 3600, 191)

    @attr("integration")
    def testDestroyProxy(self):
        """
        Test the proxy destroy method.
        """
        self.proxy.destroy()
        self.proxyPath = self.proxy.getProxyFilename()
        self.assertFalse(os.path.exists(self.proxyPath))
        # Create the proxy after the destroy
        self.proxy.create()

    @attr("integration")
    def testGetSubject(self):
        """
        _testGetSubject_
        Verify that the getSubject() method works correctly.
        """
        subject = self.proxy.getSubject()
        self.assertEqual(subject, self.getUserIdentity(), "Error: Wrong subject.")
        return

    @attr("integration")
    def testGetUserName(self):
        """
        _testGetUserName_
        Verify that the getUserName() method correctly determines the user's
        name.
        """
        user = self.proxy.getUserName()
        identity = self.getUserIdentity().split("/")[len(self.getUserIdentity().split("/")) - 1][3:]
        self.assertEqual(user, identity, "Error: User name is wrong: |%s|\n|%s|" % (user, identity))
        return

    @attr("integration")
    def testCheckAttribute(self):
        """
        Test if the checkAttribute  method checks correctly the attributes validity.
        """
        valid = self.proxy.checkAttribute()
        self.assertTrue(valid)

    @attr("integration")
    def testCheckTimeLeft(self):
        """
        Test if the check method checks correctly the proxy validity.
        """
        valid = self.proxy.check(self.proxyPath)
        self.assertTrue(valid)

    @attr("integration")
    def testVomsRenewal(self):
        """
        Test if vomsExtensionRenewal method renews correctly the voms-proxy.
        """
        proxyPath = self.proxy.getProxyFilename()
        time.sleep(70)
        attribute = self.proxy.prepareAttForVomsRenewal(self.proxy.getAttributeFromProxy(proxyPath))
        self.proxy.vomsExtensionRenewal(proxyPath, attribute)
開發者ID:vlimant,項目名稱:WMCore,代碼行數:70,代碼來源:Proxy_t.py

示例3: ProxyTest

# 需要導入模塊: from WMCore.Credential.Proxy import Proxy [as 別名]
# 或者: from WMCore.Credential.Proxy.Proxy import getUserName [as 別名]

#.........這裏部分代碼省略.........
        """
        time.sleep( 70 )
        self.proxy.renew()
        time.sleep( 10 )
        timeLeft = self.proxy.getTimeLeft()
        self.assertEqual(int(timeLeft) / 3600, 191)

    @attr("integration")
    def testDestroyProxy(self ):
        """
        Test the proxy destroy method.
        """
        self.proxy.destroy( )
        self.proxyPath = self.proxy.getProxyFilename()
        self.assertFalse(os.path.exists(self.proxyPath))
        # Create the proxy after the destroy
        self.proxy.create()

    @attr("integration")
    def testGetSubject(self):
        """
        _testGetSubject_
        Verify that the getSubject() method works correctly.
        """
        subject = self.proxy.getSubject( )
        self.assertEqual(subject, self.getUserIdentity(),
                         "Error: Wrong subject.")
        return

    @attr("integration")
    def testGetUserName( self ):
        """
        _testGetUserName_
        Verify that the getUserName() method correctly determines the user's
        name.
        """
        user = self.proxy.getUserName( )
        identity = self.getUserIdentity().split("/")[ len(self.getUserIdentity().split("/")) - 1 ][3:]
        self.assertEqual(user, identity,
                         "Error: User name is wrong: |%s|\n|%s|" % (user, identity))
        return

    @attr("integration")
    def testCheckAttribute( self ):
        """
        Test if the checkAttribute  method checks correctly the attributes validity.
        """
        valid = self.proxy.checkAttribute( )
        self.assertTrue(valid)

    @attr("integration")
    def testCheckTimeLeft( self ):
        """
        Test if the check method checks correctly the proxy validity.
        """
        valid = self.proxy.check( self.proxyPath )
        self.assertTrue(valid)

    @attr("integration")
    def testVomsRenewal( self ):
        """
        Test if vomsExtensionRenewal method renews correctly the voms-proxy.
        """
        proxyPath = self.proxy.getProxyFilename( )
        time.sleep( 70 )
        attribute = self.proxy.prepareAttForVomsRenewal( self.proxy.getAttributeFromProxy( proxyPath ) )
開發者ID:AndresTanasijczuk,項目名稱:WMCore,代碼行數:70,代碼來源:Proxy_t.py


注:本文中的WMCore.Credential.Proxy.Proxy.getUserName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。