8 confFileName =
'popcon2dropbox.json'
9 fileNameForDropBox =
'input_for_dropbox'
10 dbFileForDropBox =
'%s.db' %fileNameForDropBox
11 dbLogFile =
'%s_log.db' %fileNameForDropBox
18 with open(confFileName)
as jf:
19 self.
md = json.load(jf)
22 return self.md.get(
'authenticationPath')
25 return self.md.get(
'authenticationSystem')
28 return self.md.get(
'destinationDatabase')
31 return self.md.get(
'logDbFileName')
34 return self.md.get(
'records')
41 tags[ desttag ] = tagInfo
42 uploadMd[
'destinationTags'] = tags
43 uploadMd[
'inputTag'] = inputtag
44 uploadMd[
'since'] =
None
45 uploadMd[
'userText'] = comment
46 with open(
'%s.txt' %fileNameForDropBox,
'wb')
as jf:
47 jf.write( json.dumps( uploadMd, sort_keys=
True, indent = 2 ) )
50 def runO2O( cmsswdir, releasepath, release, arch, jobfilename, logfilename, *p ):
52 if path.exists(
'%s.db' %fileNameForDropBox ):
53 print "Removing files with name %s" %fileNameForDropBox
54 remove(
'%s.db' %fileNameForDropBox )
55 if path.exists(
'%s.txt' %fileNameForDropBox ):
56 remove(
'%s.txt' %fileNameForDropBox )
57 command =
'export SCRAM_ARCH=%s;' %arch
58 command +=
'CMSSWDIR=%s;' %cmsswdir
59 command +=
'source ${CMSSWDIR}/cmsset_default.sh;'
60 command +=
'cd %s/%s/src;' %(releasepath,release)
61 command +=
'eval `scramv1 runtime -sh`;'
64 command +=
'cmsRun %s ' %jobfilename
65 command +=
' '.
join(p)
67 pipe = subprocess.Popen( command, shell=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
68 stdout_val = pipe.communicate()[0]
74 if not path.exists( dbFileForDropBox ):
75 print 'The input sqlite file has not been produced.'
78 if path.exists(
'%s.txt' %fileNameForDropBox ):
79 remove(
'%s.txt' %fileNameForDropBox )
84 (username, account, password) = netrc.netrc().authenticators(upload_popcon.defaultNetrcHost)
86 print 'Netrc entry "DropBox" not found.'
89 dropBox.signIn(username, password)
92 for k,v
in md.records().
items():
93 destTag = v.get(
"destinationTag")
94 inputTag = v.get(
"sqliteTag")
97 comment = v.get(
"comment")
98 metadata = md.dumpMetadataForUpload( inputTag, destTag, comment )
99 ret &= dropBox.uploadFile(dbFileForDropBox, backend, upload_popcon.defaultTemporaryFile)
static std::string join(char **cmd)