本文整理匯總了Python中rapuma.core.tools.Tools.ymd方法的典型用法代碼示例。如果您正苦於以下問題:Python Tools.ymd方法的具體用法?Python Tools.ymd怎麽用?Python Tools.ymd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rapuma.core.tools.Tools
的用法示例。
在下文中一共展示了Tools.ymd方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Xetex
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import ymd [as 別名]
#.........這裏部分代碼省略.........
# Analyse the return code
if rCode == int(0) :
self.log.writeToLog(self.errorCodes['0625'], [self.local.gidTexFileName])
elif rCode in self.xetexErrorCodes :
self.log.writeToLog(self.errorCodes['0630'], [self.local.gidTexFileName, self.xetexErrorCodes[rCode], str(rCode)])
else :
self.log.writeToLog(self.errorCodes['0635'], [str(rCode)])
except Exception as e :
# If subprocess fails it might be because XeTeX did not execute
# we will try to report back something useful
self.log.writeToLog(self.errorCodes['0615'], [str(e)])
# Collect the page count and record in group (Write out at the end of the opp.)
self.projectConfig['Groups'][gid]['totalPages'] = str(PdfFileReader(open(self.local.gidPdfFile)).getNumPages())
# Write out any changes made to the project.conf file that happened during this opp.
self.tools.writeConfFile(self.projectConfig)
# Pull out pages if requested (use the same file for output)
if pgRange :
self.tools.pdftkPullPages(self.local.gidPdfFile, self.local.gidPdfFile, pgRange)
# The gidPdfFile is the residue of the last render and if approved, can be
# used for the binding process. In regard to saving and file naming, the
# gidPdfFile will be copied but never renamed. It must remain intact.
# If the user wants to save this file or use a custom name, do that now
if save and not override :
saveFileName = self.pid + '_' + gid
if cidListSubFileName :
saveFileName = saveFileName + '_' + cidListSubFileName
if pgRange :
saveFileName = saveFileName + '_pg(' + pgRange + ')'
# Add date stamp
saveFileName = saveFileName + '_' + self.tools.ymd()
# Add render file extention
saveFileName = saveFileName + '.pdf'
# Save this to the Deliverable folder (Make sure there is one)
if not os.path.isdir(self.local.projDeliverableFolder) :
os.makedirs(self.local.projDeliverableFolder)
# Final file name and path
saveFile = os.path.join(self.local.projDeliverableFolder, saveFileName)
# Copy, no news is good news
if shutil.copy(self.local.gidPdfFile, saveFile) :
self.log.writeToLog(self.errorCodes['0730'], [saveFileName])
else :
self.log.writeToLog(self.errorCodes['0720'], [saveFileName])
# If given, the override file name becomes the file name
if override :
saveFile = override
# With shutil.copy(), no news is good news
if shutil.copy(self.local.gidPdfFile, saveFile) :
self.log.writeToLog(self.errorCodes['0730'], [saveFileName])
else :
self.log.writeToLog(self.errorCodes['0720'], [saveFileName])
# Once we know the file is successfully generated, add a background if defined
viewFile = ''
if self.useBackground :
if saveFile :
viewFile = self.pg_back.addBackground(saveFile)
else :
viewFile = self.pg_back.addBackground(self.local.gidPdfFile)
# Add a timestamp and doc info if requested in addition to background
if self.useDocInfo :
示例2: ProjBinding
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import ymd [as 別名]
#.........這裏部分代碼省略.........
gidPdfFile = os.path.join(self.local.projComponentFolder, gid, gid + '.pdf')
# bindOrder[self.projectConfig['Groups'][gid]['bindingOrder']] = self.projectConfig['Groups'][gid]['bindingFile']
bindOrder[self.projectConfig['Groups'][gid]['bindingOrder']] = gidPdfFile
bindGrpNum = len(bindOrder)
# Need not keep going if nothing was found
if bindGrpNum == 0 :
self.log.writeToLog(self.errorCodes['0210'])
return False
# Make an ordered key list
keyList = bindOrder.keys()
keyList.sort()
# Output the bind files in order according to the list we made
fileList = []
for key in keyList :
fileList.append(bindOrder[key])
# First merge the master pages together
tempFile = self.mergePdfFilesGs(fileList)
# Now add background and doc info if requested
bgFile = ''
if self.useBackground :
bgFile = self.pg_back.addBackground(tempFile)
if self.useDocInfo :
if bgFile :
bgFile = self.pg_back.addDocInfo(bgFile)
else :
bgFile = self.pg_back.addDocInfo(tempFile)
# If we are saving this make a name for it
if save :
bindFileName = self.pid + '_contents_' + self.tools.ymd()
# Save this to the Deliverable folder (Make sure there is one)
if not os.path.isdir(self.local.projDeliverableFolder) :
os.makedirs(self.local.projDeliverableFolder)
bindFile = os.path.join(self.local.projDeliverableFolder, bindFileName + '.pdf')
if os.path.exists(bgFile) :
if shutil.copy(bgFile, bindFile) :
self.log.writeToLog(self.errorCodes['0220'], [bgFile,bindFile])
else :
if shutil.copy(tempFile, bindFile) :
self.log.writeToLog(self.errorCodes['0220'], [tempFile,bindFile])
# Direct to viewFile
viewFile = bindFile
else :
if os.path.exists(bgFile) :
viewFile = bgFile
else :
viewFile = tempFile
# Binding should have been successful, report it now
self.log.writeToLog(self.errorCodes['0230'], [viewFile])
# View the file
if os.path.isfile(viewFile) :
if self.pdfViewerCmd :
# Add the file to the viewer command
self.pdfViewerCmd.append(viewFile)
# Run the viewer
try :
subprocess.Popen(self.pdfViewerCmd)
return True
示例3: Pdftk
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import ymd [as 別名]
#.........這裏部分代碼省略.........
cidList = self.projectConfig['Groups'][gid]['cidList']
# Make a list of files that pdftk will merge together
sourceList = self.sourceListFromCidList(cidList)
# Merge the files
cmd = ['pdftk'] + sourceList + ['cat', 'output', self.local.gidPdfFile]
# import pdb; pdb.set_trace()
# No return from pdftk is good, we can continue on
if not subprocess.call(cmd) :
# Collect the page count and record in group (Write out at the end of the opp.)
self.projectConfig['Groups'][gid]['totalPages'] = str(PdfFileReader(open(self.local.gidPdfFile)).getNumPages())
# Write out any changes made to the project.conf file that happened during this opp.
self.tools.writeConfFile(self.projectConfig)
# Pull out pages if requested (use the same file for output)
if pgRange :
self.tools.pdftkPullPages(self.local.gidPdfFile, self.local.gidPdfFile, pgRange)
# The gidPdfFile is the residue of the last render and if approved, can be
# used for the binding process. In regard to saving and file naming, the
# gidPdfFile will be copied but never renamed. It must remain intact.
# If the user wants to save this file or use a custom name, do that now
if save and not override :
saveFileName = self.pid + '_' + gid
if cidListSubFileName :
saveFileName = saveFileName + '_' + cidListSubFileName
if pgRange :
saveFileName = saveFileName + '_pg(' + pgRange + ')'
# Add date stamp
saveFileName = saveFileName + '_' + self.tools.ymd()
# Add render file extention
saveFileName = saveFileName + '.pdf'
# Save this to the Deliverable folder (Make sure there is one)
if not os.path.isdir(self.local.projDeliverableFolder) :
os.makedirs(self.local.projDeliverableFolder)
# Final file name and path
saveFile = os.path.join(self.local.projDeliverableFolder, saveFileName)
# Copy, no news is good news
if shutil.copy(self.local.gidPdfFile, saveFile) :
self.log.writeToLog(self.errorCodes['5730'], [saveFileName])
else :
self.log.writeToLog(self.errorCodes['5720'], [saveFileName])
# If given, the override file name becomes the file name
if override :
saveFile = override
# With shutil.copy(), no news is good news
if shutil.copy(self.local.gidPdfFile, saveFile) :
self.log.writeToLog(self.errorCodes['5730'], [saveFileName])
else :
self.log.writeToLog(self.errorCodes['5720'], [saveFileName])
# Once we know the file is successfully generated, add a background if defined
if self.useBackground :
if saveFile :
viewFile = self.pg_back.addBackground(saveFile)
else :
viewFile = self.pg_back.addBackground(self.local.gidPdfFile)
# Add a timestamp and doc info if requested in addition to background
if self.useDocInfo :
if saveFile :
示例4: ProjBinding
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import ymd [as 別名]
#.........這裏部分代碼省略.........
gidPdfFile = os.path.join(self.local.projComponentFolder, gid, gid + '.pdf')
# bindOrder[self.projectConfig['Groups'][gid]['bindingOrder']] = self.projectConfig['Groups'][gid]['bindingFile']
bindOrder[self.projectConfig['Groups'][gid]['bindingOrder']] = gidPdfFile
bindGrpNum = len(bindOrder)
# Need not keep going if nothing was found
if bindGrpNum == 0 :
self.log.writeToLog(self.errorCodes['0210'])
return False
# Make an ordered key list
keyList = bindOrder.keys()
keyList.sort()
# Output the bind files in order according to the list we made
fileList = []
for key in keyList :
fileList.append(bindOrder[key])
# First merge the master pages together
tempFile = self.mergePdfFilesGs(fileList)
# Now add background and doc info if requested
bgFile = ''
if self.useBackground :
bgFile = self.pg_back.addBackground(tempFile)
if self.useDocInfo :
if bgFile :
bgFile = self.pg_back.addDocInfo(bgFile)
else :
bgFile = self.pg_back.addDocInfo(tempFile)
# If we are saving this make a name for it
if save :
bindFileName = self.pid + '_contents_' + self.tools.ymd()
# Save this to the Deliverable folder (Make sure there is one)
if not os.path.isdir(self.local.projDeliverableFolder) :
os.makedirs(self.local.projDeliverableFolder)
bindFile = os.path.join(self.local.projDeliverableFolder, bindFileName + '.pdf')
if os.path.exists(bgFile) :
if shutil.copy(bgFile, bindFile) :
self.log.writeToLog(self.errorCodes['0220'], [bgFile,bindFile])
else :
if shutil.copy(tempFile, bindFile) :
self.log.writeToLog(self.errorCodes['0220'], [tempFile,bindFile])
# Direct to viewFile
viewFile = bindFile
else :
if os.path.exists(bgFile) :
viewFile = bgFile
else :
viewFile = tempFile
# Binding should have been successful, report it now
self.log.writeToLog(self.errorCodes['0230'], [viewFile])
# View the file
if os.path.isfile(viewFile) :
if not len(self.pdfViewerCmd[0]) == 0 :
# Add the file to the viewer command
self.pdfViewerCmd.append(viewFile)
# Run the viewer
try :
subprocess.Popen(self.pdfViewerCmd)
return True