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


Python Job.cmd方法代码示例

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


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

示例1: do_job

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import cmd [as 别名]
 def do_job(self, line):
     conn = self.conn()
     if conn:
         #print "Line = %s" % line
         r = cmd.Cmd.parseline(self, line)
         print "job = " , r
         if r[0] and r[1]:
             print "Sending JOB : %s" % r[0]
             conn.send('job')
             ## On doit recevoir  Ok send your job
             print "Srv => ", conn.recv()
             j=Job()
             j.name=r[0]
             j.cmd=r[1]
             conn.send(j)
             ## On doit recevoir Job receiveing ou erreur "
             print "Srv => ", conn.recv()
             ## On doit recevoir Job job finish"
             print "Srv => ", conn.recv()
             ## On doit recevoir le job
             j = conn.recv()
             ## On doit recevoir Invite de fin OK see your soon"
             print "Srv => ", conn.recv()
             ## la connexion doit se terminer
             ## Affichage du resultat
             j.pr()
         else:
             print "Job incorrecte [%s] [%s]" % (r[0], r[1])
     else:
         print "Not connected"
     ## Dans tout les cas la connexion est ferme
     conn=None
开发者ID:chrislyon,项目名称:my-ordo-project,代码行数:34,代码来源:cli_sav.py

示例2: render

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import cmd [as 别名]
    def render(self, request):
        if request.args.has_key("string"):
            string = request.args["string"][0]
            j = Job()
            j.name = "JOB 0001"
            j.cmd = string
            self.worker.job = j
            self.worker.work()
            #rc, err, out, cmd, ilog  = self.worker.work(string)
            rc = j.returncode
            err = j.stderr
            out = j.stdout
            cmd = j.cmd
            ilog = j.ilog
        else:
            rc, err, out, cmd, ilog  = ( 0, "", "", "<>", [] )

        rep = """
        <html><body><form>
        <input type='text' name='string' value='%s' />
        <input type='submit' value='Go' />
        """
        rep += "<hr/>"
        rep += "<table border=1>"
        rep += "<tr>"
        rep += "<th> Libelle </th>"
        rep += "<th> Valeur  </th>"
        rep += "</tr>"

        rep += "<tr>"
        rep += "<td> Commande  </td>"
        rep += "<td>  %s </td>" % cmd
        rep += "</tr>"

        rep += "<tr>"
        rep += "<td> stderr </td>"
        rep += "<td>  %s </td>" % err
        rep += "</tr>"

        rep += "<tr>"
        rep += "<td> stdout </td>"
        rep += "<td>  %s </td>" % out
        rep += "</tr>"

        for l in ilog:
            rep += "<tr>"
            rep += "<td></td>"
            rep += "<td> %s </td>" % l
            rep += "</tr>"

        rep += "</table>"
        rep +=  """
        </form></body></html>
        """
               
        return rep
开发者ID:chrislyon,项目名称:my-ordo-project,代码行数:58,代码来源:agent.py

示例3: do_batch

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import cmd [as 别名]
 def do_batch(self, line):
     #print "Line = %s" % line
     r = cmd.Cmd.parseline(self, line)
     #print "job = " , r
     if r[0] and r[1]:
         conn = self.conn()
         ## la il faut passer la main
         ## a process
         j = Job()
         j.name = r[0]
         j.cmd = r[1]
         b = Process(target=run_batch, args=(j,conn,self.b_list))
         b.start()
     else:
         print "Job incorrecte [%s] [%s]" % (r[0], r[1])
开发者ID:chrislyon,项目名称:my-ordo-project,代码行数:17,代码来源:cli.py

示例4: lineReceived

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import cmd [as 别名]
    def lineReceived(self, line):
        if hasattr(self, 'handle_' + line):
            getattr(self, 'handle_' + line)()
        else:
            ## ce n'est une fonction interne 
            ## donc c'est une commande a passer
            ## on doit creer un job 
            j = Job()
            j.name = "JOB 0001"
            j.cmd = line
            self.factory.worker.job = j
            self.factory.worker.work()
            #rc, err, out, cmd, ilog = self.factory.worker.work()
            self.sendLine( "Commande : %s " % j.cmd )
            self.sendLine( "Return Code = %s " % j.returncode )
            if j.stderr:
                self.sendLine( "Err = %s" % j.stderr )
            if j.stdout:
                self.sendLine( "Out = %s" % j.stdout )

            for l in j.ilog:
                self.sendLine( "> %s " % l )
开发者ID:chrislyon,项目名称:my-ordo-project,代码行数:24,代码来源:agent.py

示例5: Client

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import cmd [as 别名]
import sys
from multiprocessing.connection import Client
from array import array

from job import Job

address = ('localhost', 6000)
conn = Client(address, authkey='secret password')

print conn.recv()   # Entete du serveur

if sys.argv[1]:
    conn.send(sys.argv[1])
else:
    j=Job()
    j.name='TEST'
    j.cmd="ls -l"
    conn.send(j)

print conn.recv()   # Entete du serveur

conn.close()
开发者ID:chrislyon,项目名称:my-ordo-project,代码行数:24,代码来源:cli.py

示例6: Client

# 需要导入模块: from job import Job [as 别名]
# 或者: from job.Job import cmd [as 别名]
PORT=6000
PASSWORD='secret password'
address = (SERVEUR, PORT)
conn = Client(address, authkey=PASSWORD)

print conn.recv()   # Entete du serveur

if len(sys.argv) > 1 :
    cmd=sys.argv[1]
    if cmd == 'j1':
        print "Cli : JOB1"
        conn.send('job')
        print "Srv => ", conn.recv()
        j=Job()
        j.name='TYPE JOB 1'
        j.cmd="ls -l ; sleep 55"
        #j.cmd="ls -l "
        conn.send(j)
        j = conn.recv()
        j.pr()
        conn.close()
    elif cmd == 'j2':
        print "Cli : JOB2"
        conn.send('job')
        print "Srv => ", conn.recv()
        j=Job()
        j.name='TYPE JOB 2'
        j.cmd="ls -l ; sleep 25"
        #j.cmd="ls -l "
        conn.send(j)
        j = conn.recv()
开发者ID:chrislyon,项目名称:my-ordo-project,代码行数:33,代码来源:test_jobs.py


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