Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • field-science/terrestrial-mapping-platform
1 result
Show changes
Commits on Source (2)
...@@ -13,11 +13,16 @@ ...@@ -13,11 +13,16 @@
# Google Sheets: .xslx, .ods, .csv, .tsv, .pdf, and .html # Google Sheets: .xslx, .ods, .csv, .tsv, .pdf, and .html
# Google Slides: .pptx, .pdf, .svg, .jpg, .png, and .txt # Google Slides: .pptx, .pdf, .svg, .jpg, .png, and .txt
# Google Drawings: pdf, .svg, .jpg, .png # Google Drawings: pdf, .svg, .jpg, .png
# Files:
# todo # todo
# test on all machines (py2 or py3 code?) # test on all machines (py2 or py3 code?)
# look for -i error in log to determine success? (in fetchObject()) # look for -i error in log to determine success? (in fetchObject())
# support presentation drawings text # slide is the language used elsewhere # support for other object types:
# file - done
# presentation
# drawings # slide is the language used elsewhere
# text
# pylint # pylint
# test under osx so that people can use it on their local machines to fetch workflows # test under osx so that people can use it on their local machines to fetch workflows
...@@ -33,6 +38,9 @@ def fetchObject(documentId, objectType, outputFormat, outputName, logFile): ...@@ -33,6 +38,9 @@ def fetchObject(documentId, objectType, outputFormat, outputName, logFile):
elif objectType == 'doc': elif objectType == 'doc':
location = 'document/d/' location = 'document/d/'
elif objectType == 'file':
location = 'file/d/'
# DOC_ID=1olFTlH4ssJIv01n40-44BIDda0OkXcFhXj-SLVtZwks # DOC_ID=1olFTlH4ssJIv01n40-44BIDda0OkXcFhXj-SLVtZwks
command = 'wget --output-file=' + logFile + ' \"' + base + location + documentId + '/export?format=' + outputFormat command = 'wget --output-file=' + logFile + ' \"' + base + location + documentId + '/export?format=' + outputFormat
...@@ -43,6 +51,7 @@ def fetchObject(documentId, objectType, outputFormat, outputName, logFile): ...@@ -43,6 +51,7 @@ def fetchObject(documentId, objectType, outputFormat, outputName, logFile):
command = command + '\" ' command = command + '\" '
command = command + '-O ' + outputName command = command + '-O ' + outputName
_status = os.system(command) _status = os.system(command)
return _status return _status
...@@ -52,7 +61,7 @@ if __name__ == "__main__": ...@@ -52,7 +61,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description='fetch-gdrive-object') parser = argparse.ArgumentParser(description='fetch-gdrive-object')
parser.add_argument('-d','--documentId', type=str, help='GDrive Document ID', required=True) parser.add_argument('-d','--documentId', type=str, help='GDrive Document ID', required=True)
parser.add_argument('-t','--objectType', type=str, choices=['doc', 'sheet'], help='Object type {doc, sheet}', required=True) parser.add_argument('-t','--objectType', type=str, choices=['doc', 'sheet', 'file'], help='Object type {doc, sheet, file}', required=True)
parser.add_argument('-f','--outputFormat', type=str, help='Output format (must fit type)', required=True) parser.add_argument('-f','--outputFormat', type=str, help='Output format (must fit type)', required=True)
parser.add_argument('-o','--outputName', type=str, help='Output file name', required=True) parser.add_argument('-o','--outputName', type=str, help='Output file name', required=True)
args = parser.parse_args() args = parser.parse_args()
...@@ -68,6 +77,9 @@ if __name__ == "__main__": ...@@ -68,6 +77,9 @@ if __name__ == "__main__":
elif args.objectType == 'sheet' and args.outputFormat in ['xslx', 'ods', 'csv', 'tsv', 'pdf', 'html']: elif args.objectType == 'sheet' and args.outputFormat in ['xslx', 'ods', 'csv', 'tsv', 'pdf', 'html']:
status = fetchObject(args.documentId, args.objectType, args.outputFormat, args.outputName, logFile) status = fetchObject(args.documentId, args.objectType, args.outputFormat, args.outputName, logFile)
elif args.objectType == 'file' and args.outputFormat in ['xslx', 'ods', 'csv', 'tsv', 'pdf', 'html', 'jpg', 'png']:
status = fetchObject(args.documentId, args.objectType, args.outputFormat, args.outputName, logFile)
else: else:
print('fetch-gdrive-object: error, unsupported objectType or objectType outputFormat combination') print('fetch-gdrive-object: error, unsupported objectType or objectType outputFormat combination')
exit(-1) exit(-1)
......