Skip to content

Commit 047adc4

Browse files
committed
fixed code block sequencing & encoding of values
1 parent 8a01548 commit 047adc4

17 files changed

+151
-137
lines changed

addKeyValuePairToCollection.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
import urllib3
88
import argparse
99

10+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
11+
if secretsVersion != '':
12+
try:
13+
secrets = __import__(secretsVersion)
14+
print 'Editing Production'
15+
except ImportError:
16+
print 'Editing Stage'
17+
else:
18+
print 'Editing Stage'
19+
1020
parser = argparse.ArgumentParser()
1121
parser.add_argument('-k', '--key', help='the key to be added. optional - if not provided, the script will ask for input')
1222
parser.add_argument('-v', '--value', help='the value to be added. optional - if not provided, the script will ask for input')
@@ -33,16 +43,6 @@
3343

3444
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
3545

36-
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
37-
if secretsVersion != '':
38-
try:
39-
secrets = __import__(secretsVersion)
40-
print 'Editing Production'
41-
except ImportError:
42-
print 'Editing Stage'
43-
else:
44-
print 'Editing Stage'
45-
4646
baseURL = secrets.baseURL
4747
email = secrets.email
4848
password = secrets.password

addKeyValuePairToCommunity.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
import urllib3
88
import argparse
99

10+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
11+
if secretsVersion != '':
12+
try:
13+
secrets = __import__(secretsVersion)
14+
print 'Editing Production'
15+
except ImportError:
16+
print 'Editing Stage'
17+
else:
18+
print 'Editing Stage'
19+
1020
parser = argparse.ArgumentParser()
1121
parser.add_argument('-k', '--key', help='the key to be added. optional - if not provided, the script will ask for input')
1222
parser.add_argument('-v', '--value', help='the value to be added. optional - if not provided, the script will ask for input')
@@ -33,16 +43,6 @@
3343

3444
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
3545

36-
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
37-
if secretsVersion != '':
38-
try:
39-
secrets = __import__(secretsVersion)
40-
print 'Editing Production'
41-
except ImportError:
42-
print 'Editing Stage'
43-
else:
44-
print 'Editing Stage'
45-
4646
baseURL = secrets.baseURL
4747
email = secrets.email
4848
password = secrets.password

addNewItemsToCollection.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
import collections
1010
import argparse
1111

12+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
13+
if secretsVersion != '':
14+
try:
15+
secrets = __import__(secretsVersion)
16+
print 'Editing Production'
17+
except ImportError:
18+
print 'Editing Stage'
19+
else:
20+
print 'Editing Stage'
21+
1222
parser = argparse.ArgumentParser()
1323
parser.add_argument('-d', '--directory', help='the directory of files to be ingested. optional - if not provided, the script will ask for input')
1424
parser.add_argument('-e', '--fileExtension', help='the extension of files to be ingested. optional - if not provided, the script will ask for input')
@@ -30,16 +40,6 @@
3040

3141
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
3242

33-
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
34-
if secretsVersion != '':
35-
try:
36-
secrets = __import__(secretsVersion)
37-
print 'Editing Production'
38-
except ImportError:
39-
print 'Editing Stage'
40-
else:
41-
print 'Editing Stage'
42-
4343
baseURL = secrets.baseURL
4444
email = secrets.email
4545
password = secrets.password

deleteKeyFromCollection.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
import urllib3
88
import argparse
99

10+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
11+
if secretsVersion != '':
12+
try:
13+
secrets = __import__(secretsVersion)
14+
print 'Editing Production'
15+
except ImportError:
16+
print 'Editing Stage'
17+
else:
18+
print 'Editing Stage'
19+
1020
parser = argparse.ArgumentParser()
1121
parser.add_argument('-k', '--deletedKey', help='the key to be deleted. optional - if not provided, the script will ask for input')
1222
parser.add_argument('-i', '--handle', help='handle of the collection to retreive. optional - if not provided, the script will ask for input')
@@ -24,16 +34,6 @@
2434

2535
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
2636

27-
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
28-
if secretsVersion != '':
29-
try:
30-
secrets = __import__(secretsVersion)
31-
print 'Editing Production'
32-
except ImportError:
33-
print 'Editing Stage'
34-
else:
35-
print 'Editing Stage'
36-
3737
baseURL = secrets.baseURL
3838
email = secrets.email
3939
password = secrets.password

deleteKeyFromCommunity.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
import urllib3
88
import argparse
99

10+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
11+
if secretsVersion != '':
12+
try:
13+
secrets = __import__(secretsVersion)
14+
print 'Editing Production'
15+
except ImportError:
16+
print 'Editing Stage'
17+
else:
18+
print 'Editing Stage'
19+
1020
parser = argparse.ArgumentParser()
1121
parser.add_argument('-k', '--deletedKey', help='the key to be deleted. optional - if not provided, the script will ask for input')
1222
parser.add_argument('-i', '--handle', help='handle of the community to retreive. optional - if not provided, the script will ask for input')
@@ -24,14 +34,6 @@
2434

2535
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
2636

27-
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
28-
if secretsVersion != '':
29-
try:
30-
secrets = __import__(secretsVersion)
31-
print 'Editing Production'
32-
except ImportError:
33-
print 'Editing Stage'
34-
3537
baseURL = secrets.baseURL
3638
email = secrets.email
3739
password = secrets.password

editBitstreamsNames.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@
77
from datetime import datetime
88
import argparse
99

10-
parser = argparse.ArgumentParser()
11-
parser.add_argument('-f', '--fileName', help='the name of the CSV with the bitstream name changes. optional - if not provided, the script will ask for input')
12-
args = parser.parse_args()
13-
if args.uri:
14-
fileName = args.fileName
15-
else:
16-
fileName = raw_input('Enter file name: ')
17-
18-
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
19-
2010
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
2111
if secretsVersion != '':
2212
try:
@@ -26,6 +16,16 @@
2616
print 'Editing Stage'
2717
else:
2818
print 'Editing Stage'
19+
20+
parser = argparse.ArgumentParser()
21+
parser.add_argument('-f', '--fileName', help='the name of the CSV with the bitstream name changes. optional - if not provided, the script will ask for input')
22+
args = parser.parse_args()
23+
if args.uri:
24+
fileName = args.fileName
25+
else:
26+
fileName = raw_input('Enter file name: ')
27+
28+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
2929

3030
baseURL = secrets.baseURL
3131
email = secrets.email

overwriteExistingMetadata.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@
77
import urllib3
88
import argparse
99

10-
parser = argparse.ArgumentParser()
11-
parser.add_argument('-f', '--fileName', help='the name of the CSV with handles and file identifiers. optional - if not provided, the script will ask for input')
12-
args = parser.parse_args()
13-
if args.fileName:
14-
fileName = args.fileName
15-
else:
16-
fileName = raw_input('Enter file name: ')
17-
18-
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
19-
2010
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
2111
if secretsVersion != '':
2212
try:
@@ -27,6 +17,16 @@
2717
else:
2818
print 'Editing Stage'
2919

20+
parser = argparse.ArgumentParser()
21+
parser.add_argument('-f', '--fileName', help='the name of the CSV with handles and file identifiers. optional - if not provided, the script will ask for input')
22+
args = parser.parse_args()
23+
if args.fileName:
24+
fileName = args.fileName
25+
else:
26+
fileName = raw_input('Enter file name: ')
27+
28+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
29+
3030
baseURL = secrets.baseURL
3131
email = secrets.email
3232
password = secrets.password

postCollection.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
import urllib3
99
import argparse
1010

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+
1121
parser = argparse.ArgumentParser()
1222
parser.add_argument('-d', '--directory', help='the directory of the files. optional - if not provided, the script will ask for input')
1323
parser.add_argument('-e', '--fileExtension', help='the file extension. optional - if not provided, the script will ask for input')
@@ -34,16 +44,6 @@
3444

3545
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
3646

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-
4747
baseURL = secrets.baseURL
4848
email = secrets.email
4949
password = secrets.password
@@ -141,7 +141,7 @@
141141
fileName = bitstream[bitstream.rfind('/')+1:]
142142
data = open(bitstream, 'rb')
143143
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)
145145

146146
#Create provenance notes
147147
provNote = {}
@@ -175,8 +175,8 @@
175175

176176
#Post provenance notes
177177
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)
180180

181181
logout = requests.post(baseURL+'/rest/logout', headers=header, cookies=cookies, verify=verify)
182182

replaceKey.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
import urllib3
88
import argparse
99

10+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
11+
if secretsVersion != '':
12+
try:
13+
secrets = __import__(secretsVersion)
14+
print 'Editing Production'
15+
except ImportError:
16+
print 'Editing Stage'
17+
else:
18+
print 'Editing Stage'
19+
1020
parser = argparse.ArgumentParser()
1121
parser.add_argument('-1', '--replacedKey', help='the key to be replaced. optional - if not provided, the script will ask for input')
1222
parser.add_argument('-2', '--replacementKey', help='the replacement key. optional - if not provided, the script will ask for input')
@@ -23,16 +33,6 @@
2333

2434
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
2535

26-
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
27-
if secretsVersion != '':
28-
try:
29-
secrets = __import__(secretsVersion)
30-
print 'Editing Production'
31-
except ImportError:
32-
print 'Editing Stage'
33-
else:
34-
print 'Editing Stage'
35-
3636
baseURL = secrets.baseURL
3737
email = secrets.email
3838
password = secrets.password

replaceKeyForCollection.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
import urllib3
88
import argparse
99

10+
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
11+
if secretsVersion != '':
12+
try:
13+
secrets = __import__(secretsVersion)
14+
print 'Editing Production'
15+
except ImportError:
16+
print 'Editing Stage'
17+
else:
18+
print 'Editing Stage'
19+
1020
parser = argparse.ArgumentParser()
1121
parser.add_argument('-1', '--replacedKey', help='the key to be replaced. optional - if not provided, the script will ask for input')
1222
parser.add_argument('-2', '--replacementKey', help='the replacement key. optional - if not provided, the script will ask for input')
@@ -28,16 +38,6 @@
2838

2939
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
3040

31-
secretsVersion = raw_input('To edit production server, enter the name of the secrets file: ')
32-
if secretsVersion != '':
33-
try:
34-
secrets = __import__(secretsVersion)
35-
print 'Editing Production'
36-
except ImportError:
37-
print 'Editing Stage'
38-
else:
39-
print 'Editing Stage'
40-
4141
baseURL = secrets.baseURL
4242
email = secrets.email
4343
password = secrets.password

0 commit comments

Comments
 (0)