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
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() j.pr() conn.close() else: print "Sending ... %s " % cmd