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


Python String.getBytes方法代码示例

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


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

示例1: __saveManifest

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
 def __saveManifest(self, oid):
     object = self.services.getStorage().getObject(oid)
     sourceId = object.getSourceId()
     manifestStr = String(self.__manifest.toString())
     object.updatePayload(sourceId,
                          ByteArrayInputStream(manifestStr.getBytes("UTF-8")))
     object.close()
开发者ID:Paul-Nguyen,项目名称:mint,代码行数:9,代码来源:nameAuthority.py

示例2: test_store_creation

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
    def test_store_creation(self):

        from com.hp.hpl.jena.tdb import TDBFactory
        from java.io import ByteArrayInputStream
        from java.lang import String

        db_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'OAC-testing.tdb')
        dataset = TDBFactory.createDataset(db_path)
        # Make sure the store was created
        assert os.path.isdir(db_path)

        # Make InputStream triples
        rdf_text = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="info:fedora/changeme:651"><rdf:type rdf:resource="oa:Annotation"></rdf:type><oa:hasBody xmlns:oa="http://www.w3.org/ns/openannotation/core/" rdf:resource="info:fedora/changeme:650"></oa:hasBody><oa:modelVersion xmlns:oa="http://www.w3.org/ns/openannotation/core/" rdf:resource="http://www.openannotation.org/spec/core/20120509.html"></oa:modelVersion><oa:generated xmlns:oa="http://www.w3.org/ns/openannotation/core/">2012-06-07T03:50:55.993000Z</oa:generated></rdf:Description><rdf:Description rdf:about="info:fedora/changeme:650"><rdf:type rdf:resource="oa:Body"></rdf:type><dc:format xmlns:dc="http://purl.org/dc/elements/1.1/">text/xml</dc:format></rdf:Description></rdf:RDF>'
        rdfxml = String(rdf_text)
        input_stream = ByteArrayInputStream(rdfxml.getBytes())

        model = dataset.getDefaultModel()
        model.begin()
        model.read(input_stream, None)
        model.commit()
        model.close()
        # Were all of the triples added?
        assert model.size() == 6

        shutil.rmtree(db_path)
        # Was the store removed?
        assert not os.path.isdir(db_path)
开发者ID:Brown-University-Library,项目名称:oac_web_service,代码行数:29,代码来源:test_store.py

示例3: __formData

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
    def __formData(self):
        # Find our workflow form data
        packagePid = None
        try:
            self.pidList = self.object.getPayloadIdList()
            for pid in self.pidList:
                if pid.endswith(self.packagePidSuffix):
                    packagePid = pid
        except StorageException:
            self.log.error("Error accessing object PID list for object '{}' ", self.oid)
            return
        if packagePid is None:
            self.log.debug("Object '{}' has no form data", self.oid)
            return

        # Retrieve our form data
        workflowData = None
        try:
            payload = self.object.getPayload(packagePid)
            try:
                workflowData = JsonSimple(payload.open())
            except Exception:
                self.log.error("Error parsing JSON '{}'", packagePid)
            finally:
                payload.close()
        except StorageException:
            self.log.error("Error accessing '{}'", packagePid)
            return

        # Test our version data
        self.version = workflowData.getString("{NO VERSION}", ["redbox:formVersion"])
        oldData = String(workflowData.toString(True))
        if self.version != self.redboxVersion:
            self.log.info("OID '{}' requires an upgrade: '{}' => '{}'", [self.oid, self.version, self.redboxVersion])
            # The version data is old, run our upgrade
            #   function to see if any alterations are
            #   required. Most likely at least the
            #   version number will change.
            newWorkflowData = self.__upgrade(workflowData)
        else:
            newWorkflowData = self.__hotfix(workflowData)
            if newWorkflowData is not None:
                self.log.debug("OID '{}' was hotfixed for v1.2 'dc:type' bug", self.oid)
            else:
                self.log.debug("OID '{}' requires no work, skipping", self.oid)
                return

        # Backup our data first
        backedUp = self.__backup(oldData)
        if not backedUp:
            self.log.error("Upgrade aborted, data backup failed!")
            return

        # Save the newly modified data
        jsonString = String(newWorkflowData.toString(True))
        inStream = ByteArrayInputStream(jsonString.getBytes("UTF-8"))
        try:
            self.object.updatePayload(packagePid, inStream)
        except StorageException, e:
            self.log.error("Error updating workflow payload: ", e)
开发者ID:andrewbrazzatti,项目名称:redbox-core-dev-build,代码行数:62,代码来源:redboxMigration1.5.py

示例4: __call__

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
    def __call__(self):
        """
        A Python object is callable if it defines a __call__ method. Each worker thread performs a
        number of runs of the test script, as configured by the property grinder.runs. For each run,
        the worker thread calls its TestRunner; thus the __call__ method can be thought of as the
        definition of a run.
        """

        # Normally test results are reported automatically when the test returns. If you want to
        # alter the statistics after a test has completed, you must set delayReports = 1 to delay
        # the reporting before performing the test. This only affects the current worker thread.
        grinder.statistics.delayReports = 1

        msg = te_message.Message(
            "1.0", "20111020153610", 200, None, "GPE-111", 111, "OPERATOR-111", "00000000001", None, request_msgbody
        )
        # print("******hello" + str(type(msg)))
        # print("msg.raw_body" + msg.raw_body)
        # print("des:" + msg.encrypted_body)
        body = String(msg.encrypted_body)
        response = request.POST(CONF_url, body.getBytes(), msg.assemble_nvpairs())

        code = int(response.getHeader("X-Response-Code"))
        # verify response status
        if 200 != code:
            print("------------------------------------ERROR: %d" % code)
            # Set success = 0 to mark the test as a failure.
            grinder.statistics.forLastTest.setSuccess(0)
        else:
            print("------------------------------------PASS!")
开发者ID:ramonli,项目名称:eGame_TE,代码行数:32,代码来源:test_lotto_sale.py

示例5: __activate__

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
    def __activate__(self, context):
        # Prepare variables
        self.index = context["fields"]
        self.object = context["object"]
        self.payload = context["payload"]
        self.params = context["params"]
        self.utils = context["pyUtils"]
        self.config = context["jsonConfig"]
        self.wfSecurityExceptions = None
        self.message_list = None

        # Because the workflow messaging system wants access to this data
        #  BEFORE it actual hits the index we are going to cache it into an
        #  object payload too.
        self.directIndex = JsonSimple()

        # Common data
        self.__newDoc()
        #print "+++ direct-files.py - itemType='%s'" % self.itemType

        # Real metadata
        if self.itemType == "object":
            self.__previews()
            self.__basicData()
            self.__metadata()
            # Update the 'direct.index' payload - BEFORE messages are sent
            directString = String(self.directIndex.toString())
            inStream = ByteArrayInputStream(directString.getBytes("UTF-8"))
            try:
                StorageUtils.createOrUpdatePayload(self.object, "direct.index", inStream)
            except StorageException, e:
                print " * direct-files.py : Error updating direct payload"
            self.__messages()
            self.__displayType()
开发者ID:the-fascinator-contrib,项目名称:builds-media-repository,代码行数:36,代码来源:direct-files.py

示例6: __saveWorkflowMetadata

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
 def __saveWorkflowMetadata(self, oid):
     object = self.services.getStorage().getObject(oid)
     manifestStr = String(self.__workflowMetadata.toString())
     object.updatePayload("workflow.metadata",
                          ByteArrayInputStream(manifestStr.getBytes("UTF-8")))
     object.close()
     
     self.__indexer.index(oid)
     self.__indexer.commit()
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:11,代码来源:nameAuthority.py

示例7: _getXmlRootFromString

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
 def _getXmlRootFromString(self, xmlString):
     """
     Parses string xml representation and returns root element
     str->Element
     @raise JavaException: XML parsing failed
     """
     xmlString = ''.join([line.strip() for line in xmlString.split('\n') if line])
     strContent = String(xmlString)
     return SAXBuilder().build(ByteArrayInputStream(strContent.getBytes('utf-8'))).getRootElement()
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:11,代码来源:sharepoint_win_shell.py

示例8: resolveEntity

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
    def resolveEntity(self, name, publicId, baseURI, systemId):
        logger.debug("XMLExternalEntityResolver resolveEntity, name : ",
                     name, ", publicId: ", publicId, ", baseURI: ", baseURI, ", systemId: ", systemId )

        try:
            filename = systemId
            logger.debug('resolveEntity, file name: ', filename, ", path: ", self.remotePath)
            strContent = String( self.fileMonitor.getFileContent(self.remotePath + self.fsSeparator + filename ) )
            return InputSource( ByteArrayInputStream( strContent.getBytes() ) )
        except Exception, ex:
            logger.debug("XMLExternalEntityResolver Exception: ", ex )
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:13,代码来源:tomcat_by_shell.py

示例9: encrypt

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
	def encrypt(self, pystrPlaintext):
		try:
			plaintext = JavaString(pystrPlaintext)
			keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES")
			key = keyFactory.generateSecret(PBEKeySpec(self.PASSWORD))
			pbeCipher = Cipher.getInstance("PBEWithMD5AndDES")
			paramSpec = PBEParameterSpec(self.SALT, 20)
			pbeCipher.init(Cipher.ENCRYPT_MODE, key, paramSpec)
			return self._base64Encode(pbeCipher.doFinal(plaintext.getBytes()))
		except:
			raise
开发者ID:nstreet,项目名称:autodeploy,代码行数:13,代码来源:crypto.py

示例10: __readWsdlWithIBMFactory

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
def __readWsdlWithIBMFactory(wsdlData, importWsdlDocuments = 1):
    if wsdlData == None:
        raise WSDLException('WSDL Content is Null')
    else:
        from com.ibm.wsdl.factory import WSDLFactoryImpl
        wsdlfactoryIdox = WSDLFactoryImpl()
        reader = wsdlfactoryIdox.newWSDLReader()
        if importWsdlDocuments == 1:
            reader.setFeature('javax.wsdl.importDocuments', Boolean.TRUE)
        else:
            reader.setFeature('javax.wsdl.importDocuments', Boolean.FALSE)

        wsdlData = String(wsdlData.strip())
        arr = wsdlData.getBytes()
        stream = ByteArrayInputStream(arr)
        inSrc = InputSource(stream)
        defintion = reader.readWSDL(None, inSrc)
        return defintion
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:20,代码来源:Webservice_Utils.py

示例11: parseNlbProps

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
def parseNlbProps(output, resultVector, hostOSH, framework, ip):
    clusterNameAndProps = output.split('\n', 1)
    #the name of the cluster; also reflected in props that's why commented
    #clusterName = clusterNameAndProps[0]

    clusterPropsAndPortRules = re.split(PROP_RULE_SEPARATOR, clusterNameAndProps[1])

    #cut the statistics from output
    portRulesPropsString = re.split('\\s\\sStatistics:', clusterPropsAndPortRules[2])[0]
    props = Properties()

    propsString = String(clusterPropsAndPortRules[0])
    props.load(ByteArrayInputStream(propsString.getBytes('UTF-8')))

    parseRulesConfigOsh = parsePortRules(portRulesPropsString)
    nlbCluster = NlbClusterBuilder(props, parseRulesConfigOsh, hostOSH, framework, ip)
    nlbCluster.addOshToVector(resultVector)
    nlbNode = NlbSwBuilder(props, nlbCluster.getNlbClusterOSH(), hostOSH, framework)
    nlbNode.addOshToVector(resultVector)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:21,代码来源:ms_nlb_ntcmd.py

示例12: loadXmlFile

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
    def loadXmlFile(self, path, container = None, fileContent = None):
        'str, osh, str -> Document'
        saxBuilder = SAXBuilder()
        globalSettings = GeneralSettingsConfigFile.getInstance()
        #loadExternalDTD = globalSettings.getPropertyBooleanValue('loadExternalDTD', 1)
        loadExternalDTD = 1
        saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", loadExternalDTD)
        logger.debug("loadXmlFile, loadExternalDTD: ", loadExternalDTD, ", path: ", path )
        if loadExternalDTD :
            saxBuilder.setEntityResolver( XMLExternalEntityResolver( self.fileMonitor, str(path), self.shellUtils ) )
            saxBuilder.setFeature("http://xml.org/sax/features/use-entity-resolver2", 1)

        doc = None
        try:
            fileContent = fileContent or self.fileMonitor.getFileContent(path)
            if fileContent:
                try:
                    strContent = String(fileContent)
                    strContent = String(strContent.substring(0, strContent.lastIndexOf('>') + 1))
                    doc = saxBuilder.build(ByteArrayInputStream(strContent.getBytes()))
                    if container is not None:
                        cfOSH = self.createCF(container, path, fileContent)
                        if cfOSH is not None:
                            self.OSHVResult.add(cfOSH)
                except:
                    logger.debugException('Failed to load xml file:', path)

                    excMsg = traceback.format_exc()
                    logger.debug( excMsg )

        except:
            logger.debugException('Failed to get content of file:', path)

            excMsg = traceback.format_exc()
            logger.debug( excMsg )

        return doc
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:39,代码来源:tomcat_by_shell.py

示例13: __saveManifest

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
 def __saveManifest(self):
     manifestStr = String(self.__manifest.toString(True))
     self.__object.updatePayload(self.__object.getSourceId(),
                                 ByteArrayInputStream(manifestStr.getBytes("UTF-8")))
开发者ID:Deakin,项目名称:the-fascinator,代码行数:6,代码来源:manifest.py

示例14: adler32

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
def adler32(s, value=1):
    if value != 1:
        raise ValueError, "adler32 only support start value of 1"
    checksum = Adler32()
    checksum.update(String.getBytes(s, 'iso-8859-1'))
    return Long(checksum.getValue()).intValue()
开发者ID:AdrianPotter,项目名称:Pydev,代码行数:8,代码来源:zlib.py

示例15: JsonConfigHelper

# 需要导入模块: from java.lang import String [as 别名]
# 或者: from java.lang.String import getBytes [as 别名]
    except StorageException, e:
        # No workflow payload, time to create
        wfChanged = True
        wfMeta = JsonConfigHelper()
        wfMeta.set("id", WORKFLOW_ID)
        wfMeta.set("step", "pending")
        stages = jsonConfig.getJsonList("stages")
        for stage in stages:
            if stage.get("name") == "pending":
                item_security = stage.getList("visibility")
                workflow_security = stage.getList("security")

    # Has the workflow metadata changed?
    if wfChanged == True:
        jsonString = String(wfMeta.toString())
        inStream = ByteArrayInputStream(jsonString.getBytes("UTF-8"))
        try:
            StorageUtils.createOrUpdatePayload(object, "workflow.metadata", inStream)
        except StorageException, e:
            print " * workflow-harvester.py : Error updating workflow payload"

    rules.add(AddField("workflow_id", wfMeta.get("id")))
    rules.add(AddField("workflow_step", wfMeta.get("step")))
    for group in workflow_security:
        rules.add(AddField("workflow_security", group))

    # some defaults if the above failed
    if titleList == []:
       #use object's source id (i.e. most likely a filename)
       titleList.append(object.getSourceId())
    
开发者ID:kiranba,项目名称:the-fascinator,代码行数:32,代码来源:workflow-harvester.py


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