0
|
1 #!/usr/bin/env python
|
|
2
|
|
3 """
|
|
4 xena_delete.py: delete a dataset from Xena
|
|
5
|
|
6 Given the name of a Xena dataset, delete it from the local Xena database.
|
|
7 """
|
|
8
|
|
9 import argparse
|
|
10 import json
|
|
11 import os
|
|
12 import re
|
|
13 import shutil
|
|
14 import subprocess
|
|
15 import sys
|
|
16 import traceback
|
|
17 import xena_utils as xena
|
|
18
|
|
19 def main():
|
|
20 parser = argparse.ArgumentParser()
|
|
21 parser.add_argument("datasetName", type=str)
|
|
22 parser.add_argument("outfile", type=str)
|
|
23 args = parser.parse_args()
|
|
24
|
|
25 fp2 = open(args.outfile, "w")
|
|
26 xenaFileDir = xena.fileDir()
|
|
27
|
|
28 # Set up the xena delete comamnd and try to execute it. If an exception
|
|
29 # is generated, output a traceback and exit with nonzero status. If
|
|
30 # no exception was generated, indicate a successful import and exit
|
|
31 # with zero status.
|
|
32 xenaDeleteCmd = "java -jar %s --delete %s -p %s" % (xena.jarPath(),
|
|
33 args.datasetName,
|
|
34 xena.port())
|
|
35 try:
|
|
36 subprocess.call(xenaDeleteCmd, shell=True)
|
|
37 except:
|
|
38 exc_type, exc_value, exc_traceback = sys.exc_info()
|
|
39 lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
|
40 allLines = ''.join('!! ' + line for line in lines)
|
|
41 fp2.write("Unsuccessful: error %s\n" % allLines)
|
|
42 fp2.close()
|
|
43 sys.exit(-1)
|
|
44 else:
|
|
45 fp2.write( "Dataset %s deleted\n" % args.datasetName)
|
|
46 fp2.close()
|
|
47 sys.exit(0)
|
|
48
|
|
49
|
|
50 if __name__ == "__main__":
|
|
51 main()
|