|
8 | 8 | import urllib3 |
9 | 9 | import argparse |
10 | 10 |
|
| 11 | +secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ') |
| 12 | +if secretsVersion != '': |
| 13 | + try: |
| 14 | + secrets = __import__(secretsVersion) |
| 15 | + print 'Editing Production' |
| 16 | + except ImportError: |
| 17 | + print 'Editing Stage' |
| 18 | +else: |
| 19 | + print 'Editing Stage' |
| 20 | + |
11 | 21 | parser = argparse.ArgumentParser() |
12 | 22 | parser.add_argument('-d', '--directory', help='the directory of the files. optional - if not provided, the script will ask for input') |
13 | 23 | parser.add_argument('-e', '--fileExtension', help='the file extension. optional - if not provided, the script will ask for input') |
|
34 | 44 |
|
35 | 45 | urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) |
36 | 46 |
|
37 | | -secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ') |
38 | | -if secretsVersion != '': |
39 | | - try: |
40 | | - secrets = __import__(secretsVersion) |
41 | | - print 'Editing Production' |
42 | | - except ImportError: |
43 | | - print 'Editing Stage' |
44 | | -else: |
45 | | - print 'Editing Stage' |
46 | | - |
47 | 47 | baseURL = secrets.baseURL |
48 | 48 | email = secrets.email |
49 | 49 | password = secrets.password |
|
141 | 141 | fileName = bitstream[bitstream.rfind('/')+1:] |
142 | 142 | data = open(bitstream, 'rb') |
143 | 143 | post = requests.post(baseURL+itemID+'/bitstreams?name='+fileName, headers=headerFileUpload, cookies=cookies, verify=verify, data=data).json() |
144 | | - print post |
| 144 | + print json.dumps(post) |
145 | 145 |
|
146 | 146 | #Create provenance notes |
147 | 147 | provNote = {} |
|
175 | 175 |
|
176 | 176 | #Post provenance notes |
177 | 177 | provNote = json.dumps([provNote, provNote2]) |
178 | | - post = requests.put(baseURL+itemID+'/metadata', headers=header, cookies=cookies, verify=verify, data=provNote) |
179 | | - print post |
| 178 | + post = requests.put(baseURL+itemID+'/metadata', headers=header, cookies=cookies, verify=verify, data=provNote).json() |
| 179 | + print json.dumps(post) |
180 | 180 |
|
181 | 181 | logout = requests.post(baseURL+'/rest/logout', headers=header, cookies=cookies, verify=verify) |
182 | 182 |
|
|
0 commit comments