From 6c39995d192c83f2858bd2bd3c7ddf547b401ebe Mon Sep 17 00:00:00 2001 From: Ross Lazarus Date: Fri, 11 Jun 2010 21:21:33 -0400 Subject: [PATCH] Patch to upload.py for composite file uploads where the user supplies urls for components At present, the path for each component is passed as a url and there's no upload type for composite file components, so this temporary fix searches for :// in the path to figure out if this is an url upload. Not ideal and in need of a more robust repair. --- static/welcome.html | 2 +- tools/data_source/upload.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/static/welcome.html b/static/welcome.html index b90fba2ad82..598168f7df3 100644 --- a/static/welcome.html +++ b/static/welcome.html @@ -7,7 +7,7 @@
-
+
Hello world! It's running...
To customize this page edit static/welcome.html diff --git a/tools/data_source/upload.py b/tools/data_source/upload.py index 6d90107cf8b..1eba8c2fca9 100644 --- a/tools/data_source/upload.py +++ b/tools/data_source/upload.py @@ -298,12 +298,22 @@ def add_composite_file( dataset, json_file, output_path, files_path ): file_err( 'A required composite data file was not provided (%s)' % name, dataset, json_file ) break elif dataset.composite_file_paths[value.name] is not None: + dp = dataset.composite_file_paths[value.name][ 'path' ] + isurl = dp.find('://') <> -1 # todo fixme + if isurl: + try: + temp_name, dataset.is_multi_byte = sniff.stream_to_file( urllib.urlopen( dp ), prefix='url_paste' ) + except Exception, e: + file_err( 'Unable to fetch %s\n%s' % ( dp, str( e ) ), dataset, json_file ) + return + dataset.path = temp_name + dp = temp_name if not value.is_binary: if dataset.composite_file_paths[ value.name ].get( 'space_to_tab', value.space_to_tab ): - sniff.convert_newlines_sep2tabs( dataset.composite_file_paths[ value.name ][ 'path' ] ) + sniff.convert_newlines_sep2tabs( dp ) else: - sniff.convert_newlines( dataset.composite_file_paths[ value.name ][ 'path' ] ) - shutil.move( dataset.composite_file_paths[ value.name ][ 'path' ], os.path.join( files_path, name ) ) + sniff.convert_newlines( dp ) + shutil.move( dp, os.path.join( files_path, name ) ) # Move the dataset to its "real" path shutil.move( dataset.primary_file, output_path ) # Write the job info