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.
This commit is contained in:
Ross Lazarus
2010-06-11 21:21:33 -04:00
parent 243700630c
commit 6c39995d19
2 changed files with 14 additions and 4 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
</head>
<body>
<div class="document">
<div class="donemessagelarge">
<div class="warningmessagelarge">
<strong>Hello world! It's running...</strong>
<hr>
To customize this page edit <code>static/welcome.html</code>
+13 -3
View File
@@ -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