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


Python Shell.scp方法代码示例

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


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

示例1: qsub

# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import scp [as 别名]
    def qsub(self, name, host, script, template=None, kind="dict"):
        """
        Executes the qsub command on a given host.
        NOTE this method may not yet be fully implemented

        :param name: name of the script
        :param host: host on which the script is to be run
        :param script: The name of the script
        :param template: The script is wrapped into a template
        :param kind: The return is passed as dict, yaml, xml
        :return:
        """
        self.jobid_incr()
        jobscript = self.create_script(name, script, template)

        # copy the script to the remote host
        self._write_to_file(jobscript, name)
        # copy script to remote host

        remote_path = self.data.get("cloudmesh", "pbs", host, "scripts")

        print(remote_path)
        xmkdir(host, remote_path)

        manager_host = self.manager(host)

        # call qsub on the remot host
        r = Shell.scp(name, manager_host + ":" + remote_path)
        jobid = Shell.ssh(manager_host, "qsub {0}/{1}".format(remote_path, name)).rstrip()

        return self.jobstatus(host, jobid, kind=kind)
开发者ID:kwtillma,项目名称:pbs,代码行数:33,代码来源:OpenPBS.py

示例2: remote

# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import scp [as 别名]
    def remote(cls, host, force=False):
        """

        TODO: there is a bug in the instalation of kilo the openrc file on
        the remote machine is not called openrc.sh but contains username and
        project number.

        :param host: the remote host
        :param force:
        :return:
        """

        config = ConfigDict("cloudmesh.yaml")

        host_spec = config["cloudmesh.clouds." + host]
        host_credentials = host_spec["credentials"]

        if 'cm_openrc' in host_spec:
            Console.ok("looking for openrc")
        else:
            Console.error("no cm_openrc specified in the host")
            return

        hostname = config["cloudmesh.clouds." + host + ".cm_host"]
        Console.ok("fetching information from {:}  ...".format(host))

        openrc = host_spec["cm_openrc"]

        directory = os.path.dirname(openrc)
        base = os.path.basename(openrc)

        _from_dir = "{:}:{:}".format(hostname, directory).replace("~/", "")
        _to_dir = os.path.dirname(Config.path_expand(directory))
        openrc_file = Config.path_expand(openrc)
        print("From:  ", _from_dir)
        print("To:    ", _to_dir)
        print("Openrc:", openrc_file)

        cls.make_dir(_to_dir)
        r = ""
        Console.ok("Reading rc file from {}".format(host))
        try:
            r = Shell.scp('-r', _from_dir, _to_dir)
        except Exception, e:
            print(e)
            return
开发者ID:atavism,项目名称:client,代码行数:48,代码来源:register.py

示例3: run

# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import scp [as 别名]

#.........这里部分代码省略.........
            echo 'SLURM_JOB_NODELIST:' $SLURM_JOB_NODELIST
            echo 'SLURM_JOB_NUM_NODES:' $SLURM_JOB_NUM_NODES
            echo 'SLURM_MEM_BIND:' $SLURM_MEM_BIND
            echo 'SLURM_TASKS_PER_NODE:' $SLURM_TASKS_PER_NODE
            echo 'MPIRUN_NOALLOCATE:' $MPIRUN_NOALLOCATE
            echo 'MPIRUN_NOFREE:' $MPIRUN_NOFREE
            echo 'SLURM_NTASKS_PER_CORE:' $SLURM_NTASKS_PER_CORE
            echo 'SLURM_NTASKS_PER_NODE:' $SLURM_NTASKS_PER_NODE
            echo 'SLURM_NTASKS_PER_SOCKET:' $SLURM_NTASKS_PER_SOCKET
            echo 'SLURM_RESTART_COUNT:' $SLURM_RESTART_COUNT
            echo 'SLURM_SUBMIT_DIR:' $SLURM_SUBMIT_DIR
            echo 'MPIRUN_PARTITION:' $MPIRUN_PARTITION
            srun -l echo '#CLOUDMESH: Starting'
            srun -l {command}
            srun -l echo '#CLOUDMESH: Test ok'
            """
        ).format(**data).replace("\r\n", "\n").strip()

        cls.create_remote_dir(cluster, data["remote_experiment_dir"])

        _from = Config.path_expand('~/.cloudmesh/{script_name}'.format(**data))
        _to = '{cluster}:{remote_experiment_dir}'.format(**data)
        data["from"] = _from
        data["to"] = _to
        data["script"] = script
        # write the script to local
        print(_from)
        print(_to)

        with open(_from, 'w') as local_file:
            local_file.write(script)

        # copy to remote host
        Shell.scp(_from, _to)

        # delete local file
        # Shell.execute('rm', _from)
        # import sys; sys.exit()

        # run the sbatch command

        cmd = 'sbatch {remote_experiment_dir}/{script_name}'.format(**data)
        data["cmd"] = cmd

        print ("CMD>", cmd)
        result = Shell.ssh(cluster, cmd)

        data["output"] = result

        # find id
        for line in result.split("\n"):
            print ("LLL>", line)
            if "Submitted batch job" in line:
                data["id"] = int(line.replace("Submitted batch job ", "").strip())
                break


        #
        # HACK, should not depend on Model.py
        #

        # from cloudmesh_client.db.model import BATCHJOB
        # name = ""
        # BATCHJOB(name,
        #         cluster=data["cluster"],
        #         id=data["id"],
开发者ID:atavism,项目名称:client,代码行数:70,代码来源:BatchProviderSLURM.py

示例4: remote

# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import scp [as 别名]
    def remote(cls, host, force=False):
        """

        TODO: there is a bug in the instalation of kilo the openrc file on
        the remote machine is not called openrc.sh but contains username and
        project number.

        :param host: the remote host
        :param force:
        :return:
        """

        config = ConfigDict("cloudmesh.yaml")

        host_spec = config["cloudmesh.clouds." + host]
        host_credentials = host_spec["credentials"]

        if 'cm_openrc' in host_spec:
            Console.ok("looking for openrc")
        else:
            Console.error("no cm_openrc specified in the host")
            return

        hostname = config["cloudmesh.clouds." + host + ".cm_host"]
        Console.ok("fetching information from {:}  ...".format(host))

        openrc = host_spec["cm_openrc"]

        directory = os.path.dirname(openrc)
        base = os.path.basename(openrc)

        _from_dir = "{:}:{:}".format(hostname, directory + "/*").replace("~/", "")
        # _to_dir = os.path.dirname(Config.path_expand(directory))
        # FIX: Issues with path expanding on Windows
        _to_dir = os.path.realpath(
            os.path.expanduser(directory)
        )

        """
        In Windows, SCP fails with path such as 'C:\Users\...',
            and passses with '~/.cloudmesh/...'
        But on Linux machines, it fails with '~/.cloudmesh/...'
            and passes with '/home/user/...'
        Hence, adding OS check below for SCP copy directory
        """
        os_type = platform.system().lower()
        if 'windows' not in os_type:
            directory = _to_dir

        # FIX: fix for scp not working on Windows, because scp does not understand
        # paths in format: "C:/Users/<>", rather expects "~/.cloudmesh/<>"
        # openrc_file = Config.path_expand(openrc)
        openrc_file = os.path.realpath(
            os.path.expanduser(openrc)
        )
        print("From:  ", _from_dir)
        print("To:    ", _to_dir)
        print("Openrc:", openrc_file)

        cls.make_dir(_to_dir)
        r = ""
        Console.ok("Reading rc file from {}".format(host))
        try:
            r = Shell.scp('-r', _from_dir, directory)
        except Exception, e:
            print(e)
            return
开发者ID:rajaramcomputers,项目名称:client,代码行数:69,代码来源:register.py


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