comparison xena_delete.py @ 3:98b498545a52

Fixed xena_delete to delete the files from the Xena files directory as well as from the database
author melissacline
date Wed, 14 Jan 2015 16:35:12 -0800
parents 6eeb3ca663fb
children
comparison
equal deleted inserted replaced
2:6eeb3ca663fb 3:98b498545a52
31 # with zero status. 31 # with zero status.
32 xenaDeleteCmd = "java -jar %s --delete %s/%s -p %s" % (xena.jarPath(), 32 xenaDeleteCmd = "java -jar %s --delete %s/%s -p %s" % (xena.jarPath(),
33 xenaFileDir, 33 xenaFileDir,
34 args.datasetName, 34 args.datasetName,
35 xena.port()) 35 xena.port())
36 print "Issuing command", xenaDeleteCmd
37 try: 36 try:
38 subprocess.call(xenaDeleteCmd, shell=True) 37 subprocess.call(xenaDeleteCmd, shell=True)
39 except: 38 except:
40 exc_type, exc_value, exc_traceback = sys.exc_info() 39 exc_type, exc_value, exc_traceback = sys.exc_info()
41 lines = traceback.format_exception(exc_type, exc_value, exc_traceback) 40 lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
43 fp2.write("Unsuccessful: error %s\n" % allLines) 42 fp2.write("Unsuccessful: error %s\n" % allLines)
44 fp2.close() 43 fp2.close()
45 sys.exit(-1) 44 sys.exit(-1)
46 else: 45 else:
47 fp2.write( "Dataset %s deleted\n" % args.datasetName) 46 fp2.write( "Dataset %s deleted\n" % args.datasetName)
47 dataPathname = xenaFileDir + "/" + args.datasetName
48 if os.path.exists(dataPathname):
49 os.unlink(dataPathname)
50 metadataPathname = dataPathname + ".json"
51 if os.path.exists(metadataPathname):
52 os.unlink(metadataPathname)
48 fp2.close() 53 fp2.close()
49 sys.exit(0) 54 sys.exit(0)
50 55
51 56
52 if __name__ == "__main__": 57 if __name__ == "__main__":