comparison sworduploader.py @ 14:273fc80d9623

v0.5 -> New default service document, uses the GIT sword2 client code
author Marco Fabiani <marco.fabiani@eecs.qmul.ac.uk>
date Fri, 25 May 2012 13:14:05 +0100
parents cc6c7235d08a
children e24aea2d14a4
comparison
equal deleted inserted replaced
13:cc6c7235d08a 14:273fc80d9623
9 9
10 Dependencies: 10 Dependencies:
11 11
12 - python 2.X 12 - python 2.X
13 13
14 - sword2 library, with modifications: https://bitbucket.org/marcofabiani/python-sword2/src 14 - sword2 library: https://github.com/swordapp/python-client-sword2
15 15
16 ----------------------------------- 16 -----------------------------------
17 Centre for Digital Music, Queen Mary, University of London 17 Centre for Digital Music, Queen Mary, University of London
18 Copyright (c) 2012 Marco Fabiani 18 Copyright (c) 2012 Marco Fabiani
19 19
47 # Parse arguments 47 # Parse arguments
48 parser = argparse.ArgumentParser(description="Bulk upload to DSpace using SWORDv2.",epilog="If the submission is created successfully, it will remain open to be completed with the necessary metadata and licenses, using the DSpace web interface. The submission can be found in the \"My Account -> Submissions\" section of the user's area.") 48 parser = argparse.ArgumentParser(description="Bulk upload to DSpace using SWORDv2.",epilog="If the submission is created successfully, it will remain open to be completed with the necessary metadata and licenses, using the DSpace web interface. The submission can be found in the \"My Account -> Submissions\" section of the user's area.")
49 parser.add_argument("data", type=str, nargs=1, 49 parser.add_argument("data", type=str, nargs=1,
50 help="Accepts: METSDSpaceSIP and BagIt packages, simple zip files, directories, single files. NOTE: METSDSpaceSIP packages are only accepted by Collections with a workflow!") 50 help="Accepts: METSDSpaceSIP and BagIt packages, simple zip files, directories, single files. NOTE: METSDSpaceSIP packages are only accepted by Collections with a workflow!")
51 parser.add_argument("--username", dest="user_name", type=str,nargs=1, help="DSpace username.") 51 parser.add_argument("--username", dest="user_name", type=str,nargs=1, help="DSpace username.")
52 parser.add_argument("--zip", action="store_true",dest="zip",default=False, help="If \"data\" is a directory, compress it and post it as a single file. The zip file will be saved along with the individual files.")
53 parser.add_argument("--title", dest="title", type=str,nargs=1, help="Title (ignored for METS packages).") 52 parser.add_argument("--title", dest="title", type=str,nargs=1, help="Title (ignored for METS packages).")
54 parser.add_argument("--author", dest="author", type=str,nargs="+", help="Author(s) (ignored for METS packages). Accepts multiple entries in the format \"Surname, Name\"") 53 parser.add_argument("--author", dest="author", type=str,nargs="+", help="Author(s) (ignored for METS packages). Accepts multiple entries in the format \"Surname, Name\"")
55 parser.add_argument("--date", dest="date", type=str,nargs=1, help="Date of creation (string) (ignored for METS packages).") 54 parser.add_argument("--date", dest="date", type=str,nargs=1, help="Date of creation (string) (ignored for METS packages).")
55 parser.add_argument("--zip", action="store_true",dest="zip",default=False, help="If \"data\" is a directory, compress it and post it as a single file. The zip file will be saved along with the individual files.")
56 parser.add_argument("--servicedoc", dest="sd", type=str,nargs=1, help="Url of the SWORDv2 service document (default: http://c4dm.eecs.qmul.ac.uk/smdmrd-test/swordv2/servicedocument") 56 parser.add_argument("--servicedoc", dest="sd", type=str,nargs=1, help="Url of the SWORDv2 service document (default: http://c4dm.eecs.qmul.ac.uk/smdmrd-test/swordv2/servicedocument")
57 57
58 args = parser.parse_args() 58 args = parser.parse_args()
59 data = args.data[0] 59 data = args.data[0]
60 if args.zip: 60 if args.zip:
61 storezip = True 61 storezip = True
62 else: 62 else:
63 storezip = False 63 storezip = False
64 64
65 if args.sd == None: 65 if args.sd == None:
66 sd = "http://c4dm.eecs.qmul.ac.uk/smdmrd-test/swordv2/servicedocument" 66 sd = "http://c4dm.eecs.qmul.ac.uk/rdr/swordv2/servicedocument"
67 else: 67 else:
68 sd = args.sd[0] 68 sd = args.sd[0]
69 69
70 70
71 try: 71 try:
106 numColl = len(c.workspaces[0][1]) 106 numColl = len(c.workspaces[0][1])
107 for ctr in range(numColl): 107 for ctr in range(numColl):
108 coll = c.workspaces[0][1][ctr] 108 coll = c.workspaces[0][1][ctr]
109 print ctr+1,":",coll.title 109 print ctr+1,":",coll.title
110 # Select a collection to deposit into 110 # Select a collection to deposit into
111 sel = -1 111 sel = "0"
112 while (sel<=0 or sel>numColl): 112 while (not sel.isdigit() or int(sel)<=0 or int(sel)>numColl):
113 sel = input("Select a Collection to submit your files into: ") 113 sel = raw_input("Select a Collection to submit your files into: ")
114 sel = int(sel)
114 collection = c.workspaces[0][1][sel-1] 115 collection = c.workspaces[0][1][sel-1]
115 print "Selected Collection: ",collection.title 116 print "Selected Collection: ",collection.title
116 117
117 # Create a submission 118 # Create a submission
118 fileslist = [] 119 fileslist = []