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


Python TemporaryFile.readline方法代码示例

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


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

示例1: getUpdateElements

# 需要导入模块: from tempfile import TemporaryFile [as 别名]
# 或者: from tempfile.TemporaryFile import readline [as 别名]
 def getUpdateElements(self, valueMap):
     '''
     
     @param valueMap:
     '''
     
     elements = ""
     for name in valueMap.keys():
         fullname = name
         if  isinstance(name, types.StringType):
             fullname = (self.defaultNameSpace, name)        
         if  not fullname[0]:
             tag = fullname[1]        
         else:
             tag = self.shortcuts[fullname[0]] + ':' + fullname[1]
         value = valueMap[name]
         if value:
             if isinstance(value, qp_xml._element):
                 tmpFile = TemporaryFile('w+')
                 value = qp_xml.dump(tmpFile, value)
                 tmpFile.flush()
                 tmpFile.seek(0)
                 tmpFile.readline()
                 value = tmpFile.read()
             else:
                 value = "<![CDATA[%s]]>" % value
         else:
             value = ""
         elements += "<%s>%s</%s>" % (tag, value, tag)
     return elements
开发者ID:diestrin,项目名称:WebDav-Sublime,代码行数:32,代码来源:WebdavRequests.py

示例2: addValues

# 需要导入模块: from tempfile import TemporaryFile [as 别名]
# 或者: from tempfile.TemporaryFile import readline [as 别名]
    def addValues(self, values, experiment):
        if len(self.variables) == len(values):
            readyProtocol = self.info
            newProtocol = []
            for i in range(0, len(readyProtocol)):
                mystring = readyProtocol[i]
                newProtocol.append(mystring)
                for v in range(0, len(values)):
                    newProtocol[i] = newProtocol[i].replace(self.variables[v], values[v])
            from tempfile import TemporaryFile

            protocolFile = TemporaryFile(mode='r+')
            protocolFile.writelines(newProtocol)
            protocolFile.seek(0)
            line = protocolFile.readline()
            if experiment.platform != 'human':
                experiment.addComment('------ BEGIN PROTOCOL ' + self.name + ', variables: ' + ' '.join(self.variables) + '; values: ' + ' '.join(values) + ' ------')
            else:
                experiment.addComment('$')
            while line != '':
                splitline = line.split()
                LineToList(splitline, protocolFile, experiment)
                line = protocolFile.readline()
            if experiment.platform != 'human':
                experiment.addComment('------ END PROTOCOL ' + self.name + ' ------')
            else:
                experiment.addComment('$')
开发者ID:JBEI,项目名称:prpr,代码行数:29,代码来源:prparser.py

示例3: import_lang

# 需要导入模块: from tempfile import TemporaryFile [as 别名]
# 或者: from tempfile.TemporaryFile import readline [as 别名]
    def import_lang(self, cr, uid, ids, context=None):
        """
            Import Language
            @param cr: the current row, from the database cursor.
            @param uid: the current user’s ID for security checks.
            @param ids: the ID or list of IDs
            @param context: A standard dictionary
        """
        if context is None:
            context = {}
        import_data = self.browse(cr, uid, ids)[0]
        if import_data.overwrite:
            context.update(overwrite=True)
        fileobj = TemporaryFile('w+')
        fileobj.write(base64.decodestring(import_data.data))

        # now we determine the file format
        fileobj.seek(0)
        first_line = fileobj.readline().strip().replace('"', '').replace(' ', '')
        fileformat = first_line.endswith("type,name,res_id,src,value") and 'csv' or 'po'
        fileobj.seek(0)

        tools.trans_load_data(cr, fileobj, fileformat, import_data.code, lang_name=import_data.name, context=context)
        fileobj.close()
        return {}
开发者ID:Aravinthu,项目名称:openerp-server-6.1,代码行数:27,代码来源:base_import_language.py

示例4: disk

# 需要导入模块: from tempfile import TemporaryFile [as 别名]
# 或者: from tempfile.TemporaryFile import readline [as 别名]
def disk():
    """Write dummy data to a temporary file."""
    f = TemporaryFile()
    buf = '0' * 1023 + '\n'
    for _ in xrange(10):
        for _ in xrange(1024 * 8):
            f.write(buf)
        f.seek(0)
        while f.readline():
            pass

    f.close()
开发者ID:jugglinmike,项目名称:parallelizer,代码行数:14,代码来源:disk.py

示例5: _import_lang

# 需要导入模块: from tempfile import TemporaryFile [as 别名]
# 或者: from tempfile.TemporaryFile import readline [as 别名]
    def _import_lang(self, cr, uid, data, context):
        form=data['form']
        fileobj = TemporaryFile('w+')
        fileobj.write( base64.decodestring(form['data']) )

        # now we determine the file format
        fileobj.seek(0)
        first_line = fileobj.readline().strip().replace('"', '').replace(' ', '')
        fileformat = first_line.endswith("type,name,res_id,src,value") and 'csv' or 'po'
        fileobj.seek(0)

        tools.trans_load_data(cr.dbname, fileobj, fileformat, form['code'], lang_name=form['name'])
        fileobj.close()
        return {}
开发者ID:Buyanbat,项目名称:XacCRM,代码行数:16,代码来源:wizard_import_lang.py

示例6: import_lang

# 需要导入模块: from tempfile import TemporaryFile [as 别名]
# 或者: from tempfile.TemporaryFile import readline [as 别名]
 def import_lang(self, cr, uid, ids, context=None):
     if context is None:
         context = {}
     this = self.browse(cr, uid, ids[0])
     if this.overwrite:
         context = dict(context, overwrite=True)
     fileobj = TemporaryFile('w+')
     try:
         fileobj.write(base64.decodestring(this.data))
 
         # now we determine the file format
         fileobj.seek(0)
         first_line = fileobj.readline().strip().replace('"', '').replace(' ', '')
         fileformat = first_line.endswith("type,name,res_id,src,value") and 'csv' or 'po'
         fileobj.seek(0)
 
         tools.trans_load_data(cr, fileobj, fileformat, this.code, lang_name=this.name, context=context)
     finally:
         fileobj.close()
     return True
开发者ID:DarkGreising,项目名称:odoo,代码行数:22,代码来源:base_import_language.py

示例7: get_all_mountpoint

# 需要导入模块: from tempfile import TemporaryFile [as 别名]
# 或者: from tempfile.TemporaryFile import readline [as 别名]
        if line:
            element = line.split()[5]
            if element.startswith('/'):
                mountpoints.append(element)
    return mountpoints


for path in get_all_mountpoint():
    rstr = '@8qJnD&Y'
    value = 0
    try:
        fd = TemporaryFile(dir=path)
        fd.write(rstr)
        fd.flush()
        fd.seek(0)
        content = fd.readline()
        fd.close()

        if rstr != content:
            value = 1
    except OSError, IOError:
        value = 1

    record = {}
    record['metric'] = 'sys.disk.rw'
    record['endpoint'] = os.uname()[1]
    record['timestamp'] = int(time.time())
    record['step'] = 60
    record['value'] = value
    record['counterType'] = 'GAUGE'
    record['tags'] = 'mount=%s' % path
开发者ID:Scofields,项目名称:plugin,代码行数:33,代码来源:60_mountpoint_rw_test.py

示例8: configure

# 需要导入模块: from tempfile import TemporaryFile [as 别名]
# 或者: from tempfile.TemporaryFile import readline [as 别名]
  def configure(self, env):
    import params

    # generate sqconfig file
    cmd = "lscpu|grep -E '(^CPU\(s\)|^Socket\(s\))'|awk '{print $2}'"
    ofile = TemporaryFile()
    Execute(cmd,stdout=ofile)
    ofile.seek(0) # read from beginning
    core, processor = ofile.read().split('\n')[:2]
    ofile.close()

    core = int(core)-1 if int(core) <= 256 else 255

    lines = ['begin node\n']
    loc_node_list = []
    for node_id, node in enumerate(params.traf_node_list):
        # find the local hostname for each node
        cmd = "ssh -q %s hostname" % node
        ofile = TemporaryFile()
        Execute(cmd,user=params.traf_user,stdout=ofile)
        ofile.seek(0) # read from beginning
        localhn = ofile.readline().rstrip()
        ofile.close()
        cmd = "ssh %s 'echo success'" % localhn
        Execute(cmd,user=params.traf_user) # verify we can use this hostname to communicate
 
        line = 'node-id=%s;node-name=%s;cores=0-%d;processors=%s;roles=connection,aggregation,storage\n' \
                 % (node_id, localhn, core, processor)
        lines.append(line)
        loc_node_list.append(localhn)

    lines.append('end node\n')
    lines.append('\n')
    lines.append('begin overflow\n')
    for scratch_loc in params.traf_scratch.split(','):
        line = 'hdd %s\n' % scratch_loc
        lines.append(line)
    lines.append('end overflow\n')

    # write sqconfig in trafodion home dir
    trafhome = os.path.expanduser("~" + params.traf_user)
    File(os.path.join(trafhome,"sqconfig"),
         owner = params.traf_user,
         group = params.traf_user,
         content=''.join(lines),
         mode=0644)

    # install sqconfig
    Execute('source ~/.bashrc ; mv -f ~/sqconfig $TRAF_HOME/sql/scripts/',user=params.traf_user)

    # write cluster-env in trafodion home dir
    traf_nodes = ' '.join(loc_node_list)
    traf_w_nodes = '-w ' + ' -w '.join(loc_node_list)
    traf_node_count = len(loc_node_list)
    if traf_node_count != len(params.traf_node_list):
      print "Error cannot determine local hostname for all Trafodion nodes"
      exit(1)

    cl_env_temp = os.path.join(trafhome,"traf-cluster-env.sh")
    File(cl_env_temp,
         owner = params.traf_user,
         group = params.traf_user,
         content=InlineTemplate(params.traf_clust_template,
                                traf_nodes=traf_nodes,
                                traf_w_nodes=traf_w_nodes,
                                traf_node_count=traf_node_count,
                                cluster_name=params.cluster_name),
         mode=0644)

    # install cluster-env on all nodes
    for node in params.traf_node_list:
        cmd = "scp %s %s:%s/" % (cl_env_temp, node, params.traf_conf_dir)
        Execute(cmd,user=params.traf_user)
    cmd = "rm -f %s" % (cl_env_temp)
    Execute(cmd,user=params.traf_user)

    # Execute SQ gen
    Execute('source ~/.bashrc ; rm -f $TRAF_HOME/sql/scripts/sqconfig.db; sqgen',user=params.traf_user)
开发者ID:qwertyioz,项目名称:incubator-trafodion,代码行数:80,代码来源:trafodionmaster.py


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