Mercurial > repos > earlhaminst > export_to_cluster
comparison export_to_cluster.py @ 2:b97775e9fe06 draft
planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/export_to_cluster/ commit f5c5f3d6ce676937f5c673ec7fc0631a9f490dc2
author | earlhaminst |
---|---|
date | Fri, 24 Mar 2017 12:20:48 -0400 |
parents | a9d1991c90e3 |
children | 9838eed606ad |
comparison
equal
deleted
inserted
replaced
1:a9d1991c90e3 | 2:b97775e9fe06 |
---|---|
22 parser.error('Require an even number of arguments') | 22 parser.error('Require an even number of arguments') |
23 | 23 |
24 real_export_dir = os.path.realpath(options.export_dir) | 24 real_export_dir = os.path.realpath(options.export_dir) |
25 dir_prefix = options.dir_prefix.rstrip(os.sep) | 25 dir_prefix = options.dir_prefix.rstrip(os.sep) |
26 if not real_export_dir.startswith(dir_prefix): | 26 if not real_export_dir.startswith(dir_prefix): |
27 sys.exit("%s must be a subdirectory of %s" % (options.export_dir, dir_prefix)) | 27 raise Exception("%s must be a subdirectory of %s" % (options.export_dir, dir_prefix)) |
28 if not os.path.exists(real_export_dir): | 28 if not os.path.exists(real_export_dir): |
29 sys.exit("%s does not exist or it is not accessible by the Galaxy user" % options.export_dir) | 29 raise Exception("%s does not exist or it is not accessible by the Galaxy user" % options.export_dir) |
30 if not os.path.isdir(real_export_dir): | 30 if not os.path.isdir(real_export_dir): |
31 sys.exit("%s is not a directory" % options.export_dir) | 31 raise Exception("%s is not a directory" % options.export_dir) |
32 | 32 |
33 dataset_paths = args[::3] | 33 dataset_paths = args[::3] |
34 dataset_names = args[1::3] | 34 dataset_names = args[1::3] |
35 dataset_exts = args[2::3] | 35 dataset_exts = args[2::3] |
36 exit_code = 0 | |
36 for dp, dn, de in zip(dataset_paths, dataset_names, dataset_exts): | 37 for dp, dn, de in zip(dataset_paths, dataset_names, dataset_exts): |
37 """ | 38 """ |
38 Copied from get_valid_filename from django | 39 Copied from get_valid_filename from django |
39 https://github.com/django/django/blob/master/django/utils/text.py | 40 https://github.com/django/django/blob/master/django/utils/text.py |
40 """ | 41 """ |
44 try: | 45 try: |
45 shutil.copy2(dp, dest) | 46 shutil.copy2(dp, dest) |
46 print("Dataset '%s' copied to '%s'" % (dn, dest)) | 47 print("Dataset '%s' copied to '%s'" % (dn, dest)) |
47 except Exception as e: | 48 except Exception as e: |
48 msg = "Error copying dataset '%s' to '%s', %s" % (dn, dest, e) | 49 msg = "Error copying dataset '%s' to '%s', %s" % (dn, dest, e) |
49 print(msg) | 50 print(msg, file=sys.stderr) |
50 sys.stderr.write(msg) | 51 exit_code = 1 |
52 sys.exit(exit_code) |