Hello,

 

I would like to report on a Galaxy issue and the my proposed solution for it,

hopefully it will be helpful to other Galaxy users that encounter [are encountering] the same problem.

 

I tried to upload to my local Galaxy a file that I has been transferred by a FTP client.

Then, when Galaxy tried to “pull out” this file from the FTP server, the operation failed with this traceback:

 

  File "/home/galaxy/galaxy-dist/tools/data_source/upload.py", line 403, in <module>

    __main__()

  File "/home/galaxy/galaxy-dist/tools/data_source/upload.py", line 392, in __main__

    add_file( dataset, registry, json_file, output_path )

  File "/home/galaxy/galaxy-dist/tools/data_source/upload.py", line 289, in add_file

    line_count, converted_path = sniff.convert_newlines( dataset.path, in_place=in_place )

  File "/home/galaxy/galaxy-dist/lib/galaxy/datatypes/sniff.py", line 98, in convert_newlines

    shutil.move( temp_name, fname )

  File "/usr/lib64/python2.6/shutil.py", line 260, in move

    copy2(src, real_dst)

  File "/usr/lib64/python2.6/shutil.py", line 96, in copy2

    copystat(src, dst)

  File "/usr/lib64/python2.6/shutil.py", line 66, in copystat

    os.utime(dst, (st.st_atime, st.st_mtime))

OSError: [Errno 1] Operation not permitted: '/home/galaxy_upload/data_upload/…'

 

The source file that I tried to copy had  read/write permissions for all, therefore, logically, this operation should not have failed…

I read a bit about this issue and I found out that python command shutil.move might raise an OSError when it tries to move a  file to a partition where the user (galaxy in this case) has write permission but he is not the owner.

More specifically, the exception fails to modify the copystat data.

I have found a post suggesting to simply IGNORE this OSError that was raised from copystat…

Therefore, I added the following “try” statement to “galaxy-dist/lib/galaxy/datatypes/sniff.py on line 98:

                try:

                                 shutil.move( temp_name, fname )

                                  # Return number of lines in file.

                 except OSError:

                                  pass

                return ( i + 1, None )

and it solved the problem completely!

 

This is the link to the post that I took the solution from: http://bugs.python.org/issue1438480

I’m also attaching a modified “sniff.py”.

 

Hopefully, this will be helpful to other galaxy developers,

 

Best,

Liram