124 def upload( cfileName, authPath ):
128 if not os.path.exists( dbFileForDropBox ):
129 print 'The input sqlite file has not been produced.'
134 dbcon = sqlite3.connect( dbFileForDropBox )
135 dbcur = dbcon.cursor()
136 dbcur.execute(
'SELECT * FROM IOV')
137 rows = dbcur.fetchall()
142 print 'The input sqlite file produced contains no data. The upload will be skipped.'
144 except Exception
as e:
145 print 'Check on input data failed: %s' %str(e)
149 if os.path.exists(
'%s.txt' %fileNameForDropBox ):
150 os.remove(
'%s.txt' %fileNameForDropBox )
154 for k,v
in md.records().
items():
155 destTag = v.get(
"destinationTag")
156 inputTag = v.get(
"sqliteTag")
159 comment = v.get(
"comment")
160 metadata = md.dumpMetadataForUpload( inputTag, destTag, comment )
161 uploadCommand =
'uploadConditions.py %s' %fileNameForDropBox
162 if not authPath
is None:
163 uploadCommand +=
' -a %s' %authPath
165 pipe = subprocess.Popen( uploadCommand, shell=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
166 stdout = pipe.communicate()[0]
168 retCode = pipe.returncode
171 leafFolderName = md.datef.strftime(dateformatForFolder)
172 fileFolder = os.path.join( errorInUploadFileFolder, leafFolderName)
173 if not os.path.exists(fileFolder):
174 os.makedirs(fileFolder)
175 df=
'%s.db' %fileNameForDropBox
176 mf=
'%s.txt' %fileNameForDropBox
177 dataDestFile = os.path.join( fileFolder, df)
178 if not os.path.exists(dataDestFile):
179 shutil.copy2(df, dataDestFile)
180 shutil.copy2(mf,os.path.join(fileFolder,mf))
181 print "Upload failed. Data file and metadata saved in folder '%s'" %os.path.abspath(fileFolder)
183 except Exception
as e: