python类node()的实例源码

State.py 文件源码 项目:mongodb_consistent_backup 作者: Percona-Lab 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, base_dir, config, backup_time, seed_uri, argv=None):
        StateBase.__init__(self, base_dir, config)
        self.base_dir            = base_dir
        self.state['backup']     = True
        self.state['completed']  = False
        self.state['name']       = backup_time
        self.state['method']     = config.backup.method
        self.state['path']       = base_dir
        self.state['cmdline']    = argv
        self.state['config']     = config.dump()
        self.state['version']    = config.version
        self.state['git_commit'] = config.git_commit
        self.state['host']     = {
            'hostname': platform.node(),
            'uname':    platform.uname(),
            'python': {
                'build':   platform.python_build(),
                'version': platform.python_version()
            }
        }
        self.state['seed']       = {
            'uri':     seed_uri.str(),
            'replset': seed_uri.replset
        }
        self.init()
utils.py 文件源码 项目:BrundleFuzz 作者: carlosgprado 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def get_platform_info(self):
        """
        Information regarding the computer
        where the fuzzer is running
        """
        try:
            node_properties = {
                'node_name' : platform.node(),
                'os_release': platform.release(),
                'os_version': platform.version(),
                'machine'   : platform.machine(),
                'processor' : platform.processor()
            }
        except:
            self.ae.m_alert('[x] Error getting platform information')
            return None

        return node_properties
utils.py 文件源码 项目:BrundleFuzz 作者: carlosgprado 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_platform_info(self):
        """
        Information regarding the computer
        where the fuzzer is running
        """
        try:
            node_properties = {
                'node_name' : platform.node(),
                'os_release': platform.release(),
                'os_version': platform.version(),
                'machine'   : platform.machine(),
                'processor' : platform.processor()
            }
        except:
            self.ae.m_alert('[x] Error getting platform information')
            return None

        return node_properties
widgets.py 文件源码 项目:Prism 作者: Stumblinbear 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def render(self):
        view = View('none')

        box = BoxElement(title='widget.info.header', icon='server', padding=False)
        table = TableElement(
                                content=[
                                        ('widget.info.os', '%s %s (%s)' % (platform.system(), platform.release(), platform.architecture()[0])),
                                        ('widget.info.hostname', platform.node()),
                                        ('widget.info.ipaddress', prism.settings.PRISM_CONFIG['host']),
                                        ('widget.info.uptime', self.get_uptime())
                                    ]
                            )
        box.add(table)
        view.add(box)

        return view
mx.py 文件源码 项目:mx 作者: graalvm 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def parent(self, vcdir, abortOnError=True):
        self.check_for_hg()
        # We don't use run because this can be called very early before _opts is set
        try:
            out = subprocess.check_output(['hg', '-R', vcdir, 'parents', '--template', '{node}\n'])
            parents = out.rstrip('\n').split('\n')
            if len(parents) != 1:
                if abortOnError:
                    abort('hg parents returned {} parents (expected 1)'.format(len(parents)))
                return None
            return parents[0]
        except subprocess.CalledProcessError:
            if abortOnError:
                abort('hg parents failed')
            else:
                return None
mx.py 文件源码 项目:mx 作者: graalvm 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def latest(self, vcdir, rev1, rev2, abortOnError=True):
        #hg log -r 'heads(ancestors(26030a079b91) and ancestors(6245feb71195))' --template '{node}\n'
        self.check_for_hg()
        try:
            revs = [rev1, rev2]
            revsetIntersectAncestors = ' or '.join(('ancestors({})'.format(rev) for rev in revs))
            revset = 'heads({})'.format(revsetIntersectAncestors)
            out = subprocess.check_output(['hg', '-R', vcdir, 'log', '-r', revset, '--template', '{node}\n'])
            parents = out.rstrip('\n').split('\n')
            if len(parents) != 1:
                if abortOnError:
                    abort('hg log returned {} possible latest (expected 1)'.format(len(parents)))
                return None
            return parents[0]
        except subprocess.CalledProcessError:
            if abortOnError:
                abort('latest failed')
            else:
                return None
mx.py 文件源码 项目:mx 作者: graalvm 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def writexml(self, writer, indent="", addindent="", newl=""):
        writer.write(indent + "<" + self.tagName)

        attrs = self._get_attributes()
        a_names = attrs.keys()
        a_names.sort()

        for a_name in a_names:
            writer.write(" %s=\"" % a_name)
            xml.dom.minidom._write_data(writer, attrs[a_name].value)
            writer.write("\"")
        if self.childNodes:
            if not self.ownerDocument.padTextNodeWithoutSiblings and len(self.childNodes) == 1 and isinstance(self.childNodes[0], xml.dom.minidom.Text):
                # if the only child of an Element node is a Text node, then the
                # text is printed without any indentation or new line padding
                writer.write(">")
                self.childNodes[0].writexml(writer)
                writer.write("</%s>%s" % (self.tagName, newl))
            else:
                writer.write(">%s" % (newl))
                for node in self.childNodes:
                    node.writexml(writer, indent + addindent, addindent, newl)
                writer.write("%s</%s>%s" % (indent, self.tagName, newl))
        else:
            writer.write("/>%s" % (newl))
benchmark.py 文件源码 项目:runtests 作者: bccp 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, qualname, node, comm=None):

        # add the testname
        self.qualname = qualname
        self.testname = node.name # NOTE: this will include parametrized ID

        # add the qualified test path for output file
        # (removes any parametrization IDs)
        self.original_testname = node.originalname
        if self.original_testname is None:
            self.original_testname = self.testname

        # the name of the file this function should be written too
        self.filename = '.'.join(self.qualname.split('.')[:-1] + [self.original_testname])

        self.comm = comm

        # store benchmarks here
        self.benchmark = {'filename':self.filename, 'testname':self.testname}
        self.benchmark['tags'] = []

        # store meta-data here
        self.attrs = {}
inventory.py 文件源码 项目:temboard-agent 作者: dalibo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _hostname_linux(self):
        """
        Returns system hostname.
        """
        # Default value found using platform
        hostname = platform.node()
        try:
            # Try to get hostname (FQDN) using 'hostname -f'
            (rc, out, err) = exec_command([which('hostname'), '-f'])
            if rc == 0:
                hostname = out.encode('utf-8').strip()
        except Exception:
            try:
                # Try to get hostname (FQDN) using socket module
                (hostname, _, _) = socket.gethostbyaddr(socket.gethostname())
                hostname = hostname.strip()
            except Exception:
                pass
        return hostname
github.py 文件源码 项目:git-repo 作者: guyzmo 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def get_auth_token(cls, login, password, prompt=None):
        import platform
        if cls.fqdn != GITHUB_COM_FQDN:
            gh = github3.GitHubEnterprise()
        else:
            gh = github3.GitHub()
        gh.login(login, password, two_factor_callback=lambda: prompt('2FA code> '))
        try:
            auth = gh.authorize(login, password,
                    scopes=[ 'repo', 'delete_repo', 'gist' ],
                    note='git-repo2 token used on {}'.format(platform.node()),
                    note_url='https://github.com/guyzmo/git-repo')
            return auth.token
        except github3.models.GitHubError as err:
            if len(err.args) > 0 and 422 == err.args[0].status_code:
                raise ResourceExistsError("A token already exist for this machine on your github account.")
            else:
                raise err
test_platform.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_uname_win32_ARCHITEW6432(self):
        # Issue 7860: make sure we get architecture from the correct variable
        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
        # using it, per
        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
        try:
            with support.EnvironmentVarGuard() as environ:
                if 'PROCESSOR_ARCHITEW6432' in environ:
                    del environ['PROCESSOR_ARCHITEW6432']
                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'foo')
                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'bar')
        finally:
            platform._uname_cache = None
train.py 文件源码 项目:enhance 作者: cdiazbas 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, root, depth, losses, extra, **kwargs):        
        self.losses = losses
        self.losses_batch = copy.deepcopy(losses)
        self.extra = extra

        # self.f_epoch = open("/net/vena/scratch/Dropbox/GIT/DeepLearning/losses/{0}_loss.json".format(platform.node()), 'w')
        # self.f_batch = open("/net/vena/scratch/Dropbox/GIT/DeepLearning/losses/{0}_loss_batch.json".format(platform.node()), 'w')
        # self.f_epoch.write('['+json.dumps(self.extra))
        # self.f_batch.write('['+json.dumps(self.extra))

        self.f_epoch_local = open("{0}_{1}_loss.json".format(root, depth), 'w')
        self.f_batch_local = open("{0}_{1}_loss_batch.json".format(root, depth), 'w')
        self.f_epoch_local.write('['+json.dumps(self.extra))
        self.f_batch_local.write('['+json.dumps(self.extra))

        # flush_file(self.f_batch)
        flush_file(self.f_batch_local)
        # flush_file(self.f_epoch)
        flush_file(self.f_epoch_local)
app.py 文件源码 项目:mark1-gui 作者: Geeked-Out-Solutions 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def home():
    if not session.get('logged_in'):
        return render_template('login.html')
    else:
        sys_data = {"current_time": '',"machine_name": ''}
        mycroft_skills = ""
        try:
            sys_data['current_time'] = subprocess.check_output(['date'], shell=True)
            sys_data['machine_name'] = platform.node()
            sys_data['mycroft_version'] = subprocess.check_output(['dpkg -s mycroft-core | grep Version'], shell=True)
            mycroft_skills = sorted(os.listdir('/opt/mycroft/skills'))
            sys_data['skills_log'] = subprocess.check_output(['tail -n 10 /var/log/mycroft-skills.log'], shell=True)
            print(type(sys_data['skills_log']))
            disk_usage_info = disk_usage_list()
        except Exception as ex:
            print(ex)
        finally:
            return render_template("index.html", title='Mark 1 - System Information',
                                    sys_data = sys_data,
                                    name=login['username'], mycroft_skills=mycroft_skills)
index.py 文件源码 项目:mark1-gui 作者: Geeked-Out-Solutions 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def index():
 sys_data = {"current_time": '',"machine_name": ''}
 try:
     sys_data['current_time'] = datetime.now().strftime("%d-%b-%Y , %I : %M : %S %p")
     sys_data['machine_name'] =  platform.node()
     cpu_genric_info = cpu_generic_details()
     disk_usage_info = disk_usage_list()
     running_process_info = running_process_list()
 except Exception as ex:
     print ex
 finally:
     return render_template("index.html", title='Mark 1 - System Information',
                            sys_data = sys_data,
                            cpu_genric_info = cpu_genric_info,
                            disk_usage_info= disk_usage_info,
                            running_process_info = running_process_info)
alert.py 文件源码 项目:Sentences-analysis 作者: sungminoh 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def main():
    parser = argparse.ArgumentParser(description='email notification')
    parser.add_argument('--email', '-e', help='email address', required=True)
    parser.add_argument('--process', '-p', help='process', required=True)
    parser.add_argument('--title', '-t', help='email content', default='Your process is done')
    parser.add_argument('--content', '-c', help='email content')
    args = parser.parse_args()

    host = platform.node()
    process = args.process
    email = args.email
    title = args.title
    content = args.content if args.content else '{} is done'.format(process)

    print commands.getoutput('ps -ef | grep %s' % process).split('\n')
    while any([True if x.find('python %s' % process) >= 0 else False
               for x in commands.getoutput('ps -ef | grep %s' % process).split('\n')]):
        print 'sleep ...'
        sleep(300)
    send_email(title, host, email, content)
test_platform.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_uname_win32_ARCHITEW6432(self):
        # Issue 7860: make sure we get architecture from the correct variable
        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
        # using it, per
        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
        try:
            with test_support.EnvironmentVarGuard() as environ:
                if 'PROCESSOR_ARCHITEW6432' in environ:
                    del environ['PROCESSOR_ARCHITEW6432']
                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'foo')
                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'bar')
        finally:
            platform._uname_cache = None
test_platform.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_uname_win32_ARCHITEW6432(self):
        # Issue 7860: make sure we get architecture from the correct variable
        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
        # using it, per
        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
        try:
            with test_support.EnvironmentVarGuard() as environ:
                if 'PROCESSOR_ARCHITEW6432' in environ:
                    del environ['PROCESSOR_ARCHITEW6432']
                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'foo')
                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'bar')
        finally:
            platform._uname_cache = None
utils.py 文件源码 项目:py-google-auth 作者: HashGrowth 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def log_error(step, content):
    '''
    This function logs a page for error.
    It is called whenever an unhandled exception will occur.
    `step`: The step in login process, it could be normal_login, step_two_login or
    select_alternate.
            It makes it easy to identify the file in logs.
    `content`: content to log.
    '''
    file_name = step + "- " + time.strftime("%d-%m-%Y %H-%M-%S") + ".html"
    f = open(log_dir+file_name, 'w')
    f.write(content)
    f.close()

    # hostname of the machine where the py-google-auth is running
    hostname = platform.node()

    return file_name, hostname
test_platform.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_uname_win32_ARCHITEW6432(self):
        # Issue 7860: make sure we get architecture from the correct variable
        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
        # using it, per
        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
        try:
            with support.EnvironmentVarGuard() as environ:
                if 'PROCESSOR_ARCHITEW6432' in environ:
                    del environ['PROCESSOR_ARCHITEW6432']
                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'foo')
                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'bar')
        finally:
            platform._uname_cache = None
test_taskpool.py 文件源码 项目:ceph-lcm 作者: Mirantis 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_task_complete(mocked_plugin, tpool, configure_model, freeze_time):
    tsk = create_task()
    polled = {"a": False}

    def side_effect(*args, **kwargs):
        if polled["a"]:
            return False
        polled["a"] = True
        return True

    mocked_plugin.alive.side_effect = side_effect

    tpool.submit(tsk)
    assert tsk._id in tpool.data

    time.sleep(2)

    tsk.refresh()
    assert tsk.executor_host == platform.node()
    assert tsk.executor_pid == 100
    assert tsk.time_completed == int(freeze_time.return_value)
    assert not tsk.time_failed
    assert not tsk.time_cancelled
    assert not tpool.global_stop_event.is_set()
    assert tsk._id not in tpool.data
test_taskpool.py 文件源码 项目:ceph-lcm 作者: Mirantis 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_task_cancelled(mocked_plugin, tpool, configure_model, freeze_time):
    tsk = create_task()
    polled = {"a": False}

    def side_effect(*args, **kwargs):
        if polled["a"]:
            return False
        polled["a"] = True
        return True

    mocked_plugin.alive.side_effect = side_effect

    tpool.submit(tsk)
    tpool.cancel(tsk._id)

    time.sleep(2)

    tsk.refresh()
    assert tsk.executor_host == platform.node()
    assert tsk.executor_pid == 100
    assert tsk.time_cancelled == int(freeze_time.return_value)
    assert not tsk.time_completed
    assert not tsk.time_failed
    assert not tpool.global_stop_event.is_set()
    assert tsk._id not in tpool.data
test_taskpool.py 文件源码 项目:ceph-lcm 作者: Mirantis 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_task_failed_exit(mocked_plugin, tpool, configure_model, freeze_time):
    tsk = create_task()

    polled = {"a": False}

    def side_effect(*args, **kwargs):
        if polled["a"]:
            return False
        polled["a"] = True
        return True

    mocked_plugin.alive.side_effect = side_effect
    mocked_plugin.returncode = os.EX_SOFTWARE

    tpool.submit(tsk)
    time.sleep(2)
    tsk.refresh()
    assert tsk.executor_host == platform.node()
    assert tsk.executor_pid == 100
    assert tsk.time_failed == int(freeze_time.return_value)
    assert not tsk.time_cancelled
    assert not tsk.time_completed
    assert not tpool.global_stop_event.is_set()
    assert tsk._id not in tpool.data
clone.py 文件源码 项目:singularity-python 作者: singularityware 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def package_node(root=None,name=None):
    '''package node aims to package a (present working node) for a user into
    a container. This assumes that the node is a single partition.

    :param root: the root of the node to package, default is /
    :param name: the name for the image. If not specified, will use machine's

    psutil.disk_partitions()

    '''

    if name is None:
        name = platform.node()

    if root is None:
        root = "/"

    tmpdir = tempfile.mkdtemp()
    image = "%s/%s.tgz" %(tmpdir,name)

    print("Preparing to package root %s into %s" %(root,name))
    cmd = ["tar","--one-file-system","-czvSf", image, root,"--exclude",image]
    output = run_command(cmd)
    return image
test_platform.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_uname_win32_ARCHITEW6432(self):
        # Issue 7860: make sure we get architecture from the correct variable
        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
        # using it, per
        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
        try:
            with test_support.EnvironmentVarGuard() as environ:
                if 'PROCESSOR_ARCHITEW6432' in environ:
                    del environ['PROCESSOR_ARCHITEW6432']
                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'foo')
                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'bar')
        finally:
            platform._uname_cache = None
test_platform.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_uname_win32_ARCHITEW6432(self):
        # Issue 7860: make sure we get architecture from the correct variable
        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
        # using it, per
        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
        try:
            with support.EnvironmentVarGuard() as environ:
                if 'PROCESSOR_ARCHITEW6432' in environ:
                    del environ['PROCESSOR_ARCHITEW6432']
                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'foo')
                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'bar')
        finally:
            platform._uname_cache = None
test_platform.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_uname_win32_ARCHITEW6432(self):
        # Issue 7860: make sure we get architecture from the correct variable
        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
        # using it, per
        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
        try:
            with test_support.EnvironmentVarGuard() as environ:
                if 'PROCESSOR_ARCHITEW6432' in environ:
                    del environ['PROCESSOR_ARCHITEW6432']
                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'foo')
                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
                platform._uname_cache = None
                system, node, release, version, machine, processor = platform.uname()
                self.assertEqual(machine, 'bar')
        finally:
            platform._uname_cache = None
SysInfo.py 文件源码 项目:Oyster 作者: Wykleph 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_sys_info():
    info = """
Machine: {}\nVersion: {}
Platform: {}\nNode: {}\nUname: {}\nSystem: {}
Processor: {}\n\nHost Name: {}\nFQDN: {}\n
""".format(
        platform.machine(),
        platform.version(),
        platform.platform(),
        platform.node(),
        platform.uname(),
        platform.system(),
        platform.processor(),
        socket.gethostname(),
        socket.getfqdn()
    )
    return info
udocker.py 文件源码 项目:udocker 作者: indigo-dc 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _set_spec(self):
        """Set spec values"""
        json_obj = self._container_specjson
        json_obj["root"]["path"] = os.path.realpath(self.container_root)
        json_obj["root"]["readonly"] = False
        if "." in self.opt["hostname"]:
            json_obj["hostname"] = self.opt["hostname"]
        else:
            json_obj["hostname"] = platform.node()
        if self.opt["cwd"]:
            json_obj["process"]["cwd"] = self.opt["cwd"]
        json_obj["process"]["env"] = []
        for env_str in self.opt["env"]:
            (env_var, value) = env_str.split("=", 1)
            if env_var:
                json_obj["process"]["env"].append("%s=%s" % (env_var, value))
        for idmap in json_obj["linux"]["uidMappings"]:
            if "hostID" in idmap:
                idmap["hostID"] = Config.uid
        for idmap in json_obj["linux"]["gidMappings"]:
            if "hostID" in idmap:
                idmap["hostID"] = Config.gid
        json_obj["process"]["args"] = self._remove_quotes(self.opt["cmd"])
        return json_obj
environment.py 文件源码 项目:TACTIC-Handler 作者: listyque 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self):
        self.modes = ['maya', 'houdini', '3dsmax', 'nuke', 'standalone']
        self.status = False

        self.current_mode = 'standalone'
        # self.current_project = 'sthpw'
        self.current_path = None
        self.get_current_path()
        self.platform = platform.system()
        self.node = platform.node()
poster.py 文件源码 项目:django-cavalry 作者: valohai 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def build_payload(data, request, response):
    payload = {
        'node': platform.node(),
        'content-type': response.get('content-type'),
        'ip': get_ip(request),
        'method': request.method,
        'params': dict(request.GET),
        'path': request.path,
        'status': response.status_code,
        'time': datetime.utcnow(),
    }
    resolver_match = getattr(request, 'resolver_match', None)
    if resolver_match:
        payload.update({
            'view': resolver_match.view_name,
        })
    user = getattr(request, 'user', None)
    if user:
        payload.update({
            'user_id': user.id,
        })
    payload.update(data)
    payload.pop('start_time', None)
    payload.pop('end_time', None)
    payload.pop('db_record_stacks', None)
    return payload


问题


面经


文章

微信
公众号

扫码关注公众号