- import os
- import sys
-
- #Jobs:
- # JTFP-19-map #
-
- #jobsCheck change-submit //depot/server/bbb/bbb05.txt "c:\jobsCheck\jobsCheck.exe %changelist%"
-
- from subprocess import Popen, PIPE
-
- #os.environ['P4TRUST'] = '/opt/perforce/triggers/p4trust'
- os.environ['P4PORT']='1666'
- os.environ['P4CHARSET'] = 'utf8'
- os.environ['P4USER'] = 'jobuser'
- os.environ['P4PASSWD'] = '534F058A1BC50888531EC2B41517C4A1'
-
- def run_cmd(cmd):
- # Popen call wrapper.return (code, stdout, stderr)
- child = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True, env= os.environ)
- out, err = child.communicate()
- ret = child.wait()
- return (ret, out, err)
-
- def write_log(f, str):
- try:
- f.writelines(str)
- except:
- a = 1
- #try:
- # f = open("/var/p4/hxserver/bin/triggers/job.log", 'w')
- #except:
- # a = 1
-
- cmdstr = "p4 change -o " + sys.argv[1]
-
- #Popen('export', close_fds=True, shell=True, env=os.environ)
-
- (ret, r, err) = run_cmd(cmdstr)
- #print "cmdstr change:", cmdstr
- #print (ret,r, err)
-
-
- #write_log(f, "r:" + r)
- #write_log(f, "\nret: " + str(ret) + "\nerr:" + err)
-
- if ret != 0:
- print "jobcheck error."
- exit(1)
-
- job = ""
- findjobkey = False
- lines = r.split('\n')
- for i in range(len(lines)):
- x = lines[i].strip()
- if x == "" :
- continue
-
- if findjobkey == True:
- job = x
- if len(job) > 1 and job[0] != '#':
- break
- elif x.startswith("Jobs:"):
- findjobkey = True
- continue
-
-
- #write_log(f, str(findjobkey) + ","+ job + "\n")
-
- checkresult= 1
- if (len(job) > 1 and job[0] != '#'):
- # write_log(f, "\njob:" + job)
- checkresult = 0
- else:
- print "must associate change with a job."
-
- #if f:
- # f.close()
-
- exit(checkresult)
-
-
# |
Change |
User |
Description |
Committed |
|
#1
|
26725 |
Pei Li |
add check job and delete old workspaces script. |
5 years ago
|
|