diff -r 29ce93a13ac7 tools/data_source/upload.py --- a/tools/data_source/upload.py Mon Feb 10 13:22:47 2014 -0500 +++ b/tools/data_source/upload.py Tue May 27 10:54:42 2014 -0400 @@ -4,7 +4,7 @@ # WARNING: Changes in this tool (particularly as related to parsing) may need # to be reflected in galaxy.web.controllers.tool_runner and galaxy.tools -import urllib, sys, os, gzip, tempfile, shutil, re, gzip, zipfile, codecs, binascii +import urllib, sys, os, gzip, tempfile, shutil, re, gzip, zipfile, codecs, binascii, subprocess from galaxy import eggs # need to import model before sniff to resolve a circular import dependency import galaxy.model @@ -352,6 +352,19 @@ stdout = 'uploaded %s file' % dataset.file_type ) json_file.write( to_json_string( info ) + "\n" ) +def _chown( dataset ): + if ( dataset.type != 'file' ): + return + + try: + cmd = [ '/usr/bin/sudo', '-E', '/home/galaxy/server-conf/chown_script.pl', dataset.path ] + sys.stdout.write( 'Changing ownership of %s with: %s' % ( dataset.path, ' '.join( cmd ) ) ) + p = subprocess.Popen( cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) + sys.stdout.write( p.stdout.read() ) + sys.stderr.write( p.stderr.read() ) + except Exception, e: + sys.stderr.write( 'Changing ownership of uploaded file %s failed: %s' % ( dataset.path, str( e ) ) ) + def __main__(): if len( sys.argv ) < 4: @@ -372,6 +385,9 @@ except: print >>sys.stderr, 'Output path for dataset %s not found on command line' % dataset.dataset_id sys.exit( 1 ) + + _chown( dataset ) + if dataset.type == 'composite': files_path = output_paths[int( dataset.dataset_id )][1] add_composite_file( dataset, registry, json_file, output_path, files_path )