Skip to content

Commit 625eb40

Browse files
committed
instanceSelect function
1 parent a3891d4 commit 625eb40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+172
-910
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ All of these scripts require a secrets.py file in the same directory that must c
1414
filePath = '/Users/dspace_user/dspace-data-collection/data/'
1515
handlePrefix = 'http://dspace.myuni.edu/handle/'
1616
verify = True or False (no quotes). Use False if using an SSH tunnel to connect to the DSpace API
17-
skippedCollections = A list of the 'uuid' of any collections that you wish the script to skip. (e.g. ['45794375-6640-4efe-848e-082e60bae375'])
17+
skipColl = A list of the 'uuid' of any collections that you wish the script to skip. (e.g. ['45794375-6640-4efe-848e-082e60bae375'])
1818
```
1919
The 'filePath' is directory into which output files will be written and 'handlePrefix' may or may not vary from your DSpace URL depending on your configuration. This secrets.py file will be ignored according to the repository's .gitignore file so that DSpace login details will not be inadvertently exposed through GitHub.
2020

addKeyValuePairOnHandleCSV.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,9 @@
66
import urllib3
77
import dsFunc
88

9-
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
10-
11-
secretsVersion = input('To edit production server, enter the name of the \
12-
secrets file: ')
13-
if secretsVersion != '':
14-
try:
15-
secrets = __import__(secretsVersion)
16-
print('Editing Production')
17-
except ImportError:
18-
secrets = __import__('secrets')
19-
print('Editing Development')
20-
else:
21-
secrets = __import__('secrets')
22-
print('Editing Development')
9+
baseURL, email, password, filePath, verify, skipColl, sec = dsFunc.instSelect()
2310

24-
baseURL = secrets.baseURL
25-
email = secrets.email
26-
password = secrets.password
27-
filePath = secrets.filePath
28-
verify = secrets.verify
29-
skippedCollections = secrets.skippedCollections
11+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
3012

3113
startTime = time.time()
3214
data = {'email': email, 'password': password}

addKeyValuePairToCollection.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,7 @@
77
import argparse
88
import dsFunc
99

10-
secretsVersion = input('To edit production server, enter the name of the \
11-
secrets file: ')
12-
if secretsVersion != '':
13-
try:
14-
secrets = __import__(secretsVersion)
15-
print('Editing Production')
16-
except ImportError:
17-
secrets = __import__('secrets')
18-
print('Editing Development')
19-
else:
20-
secrets = __import__('secrets')
21-
print('Editing Development')
10+
baseURL, email, password, filePath, verify, skipColl, sec = dsFunc.instSelect()
2211

2312
parser = argparse.ArgumentParser()
2413
parser.add_argument('-k', '--key', help='the key to be added. optional - if \
@@ -50,13 +39,6 @@
5039

5140
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
5241

53-
baseURL = secrets.baseURL
54-
email = secrets.email
55-
password = secrets.password
56-
filePath = secrets.filePath
57-
verify = secrets.verify
58-
skippedCollections = secrets.skippedCollections
59-
6042
startTime = time.time()
6143
data = {'email': email, 'password': password}
6244
header = {'content-type': 'application/json', 'accept': 'application/json'}
@@ -91,7 +73,7 @@
9173
itemID = items[k]['uuid']
9274
itemList.append(itemID)
9375
offset = offset + 200
94-
76+
9577
dsFunc.elapsedTime(startTime, 'Item list creation time')
9678

9779
recordsEdited = 0

addKeyValuePairToCommunity.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,7 @@
77
import argparse
88
import dsFunc
99

10-
secretsVersion = input('To edit production server, enter the name of the \
11-
secrets file: ')
12-
if secretsVersion != '':
13-
try:
14-
secrets = __import__(secretsVersion)
15-
print('Editing Production')
16-
except ImportError:
17-
secrets = __import__('secrets')
18-
print('Editing Development')
19-
else:
20-
secrets = __import__('secrets')
21-
print('Editing Development')
10+
baseURL, email, password, filePath, verify, skipColl, sec = dsFunc.instSelect()
2211

2312
parser = argparse.ArgumentParser()
2413
parser.add_argument('-k', '--key', help='the key to be added. optional - if \
@@ -50,13 +39,6 @@
5039

5140
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
5241

53-
baseURL = secrets.baseURL
54-
email = secrets.email
55-
password = secrets.password
56-
filePath = secrets.filePath
57-
verify = secrets.verify
58-
skippedCollections = secrets.skippedCollections
59-
6042
startTime = time.time()
6143
data = {'email': email, 'password': password}
6244
header = {'content-type': 'application/json', 'accept': 'application/json'}
@@ -81,7 +63,7 @@
8163
verify=verify).json()
8264
for j in range(0, len(collections)):
8365
collectionID = collections[j]['uuid']
84-
if collectionID not in skippedCollections:
66+
if collectionID not in skipColl:
8567
offset = 0
8668
items = ''
8769
while items != []:
@@ -102,7 +84,7 @@
10284
itemID = items[k]['uuid']
10385
itemList.append(itemID)
10486
offset = offset + 200
105-
87+
10688
dsFunc.elapsedTime(startTime, 'Item list creation time')
10789

10890
recordsEdited = 0

addNewItemsToCollection.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,7 @@
99
import argparse
1010
import dsFunc
1111

12-
secretsVersion = input('To edit production server, enter the name of the \
13-
secrets file: ')
14-
if secretsVersion != '':
15-
try:
16-
secrets = __import__(secretsVersion)
17-
print('Editing Production')
18-
except ImportError:
19-
secrets = __import__('secrets')
20-
print('Editing Development')
21-
else:
22-
secrets = __import__('secrets')
23-
print('Editing Development')
12+
baseURL, email, password, filePath, verify, skipColl, sec = dsFunc.instSelect()
2413

2514
parser = argparse.ArgumentParser()
2615
parser.add_argument('-d', '--directory', help='the directory of files to be \
@@ -46,13 +35,6 @@
4635

4736
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
4837

49-
baseURL = secrets.baseURL
50-
email = secrets.email
51-
password = secrets.password
52-
filePath = secrets.filePath
53-
verify = secrets.verify
54-
skippedCollections = secrets.skippedCollections
55-
5638
startTime = time.time()
5739

5840
# ccreate file list and export csv

compareTwoKeysInCommunity.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,7 @@
55
import argparse
66
import dsFunc
77

8-
secretsVersion = input('To edit production server, enter the name of the \
9-
secrets file: ')
10-
if secretsVersion != '':
11-
try:
12-
secrets = __import__(secretsVersion)
13-
print('Editing Production')
14-
except ImportError:
15-
secrets = __import__('secrets')
16-
print('Editing Development')
17-
else:
18-
secrets = __import__('secrets')
19-
print('Editing Development')
8+
baseURL, email, password, filePath, verify, skipColl, sec = dsFunc.instSelect()
209

2110
parser = argparse.ArgumentParser()
2211
parser.add_argument('-1', '--key', help='the first key to be output. \
@@ -42,13 +31,6 @@
4231

4332
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
4433

45-
baseURL = secrets.baseURL
46-
email = secrets.email
47-
password = secrets.password
48-
filePath = secrets.filePath
49-
verify = secrets.verify
50-
skippedCollections = secrets.skippedCollections
51-
5234
startTime = time.time()
5335
data = {'email': email, 'password': password}
5436
header = {'content-type': 'application/json', 'accept': 'application/json'}
@@ -75,7 +57,7 @@
7557
for j in range(0, len(collections)):
7658
collectionID = collections[j]['uuid']
7759
print(collectionID)
78-
if collectionID not in skippedCollections:
60+
if collectionID not in skipColl:
7961
offset = 0
8062
items = ''
8163
while items != []:

countInitialedNamesByCollection.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,10 @@
55
import urllib3
66
import dsFunc
77

8-
secretsVersion = input('To edit production server, enter the name of the \
9-
secrets file: ')
10-
if secretsVersion != '':
11-
try:
12-
secrets = __import__(secretsVersion)
13-
print('Editing Production')
14-
except ImportError:
15-
secrets = __import__('secrets')
16-
print('Editing Development')
17-
else:
18-
secrets = __import__('secrets')
19-
print('Editing Development')
8+
baseURL, email, password, filePath, verify, skipColl, sec = dsFunc.instSelect()
209

2110
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
2211

23-
baseURL = secrets.baseURL
24-
email = secrets.email
25-
password = secrets.password
26-
filePath = secrets.filePath
27-
verify = secrets.verify
28-
skippedCollections = secrets.skippedCollections
29-
3012
startTime = time.time()
3113
data = {'email': email, 'password': password}
3214
header = {'content-type': 'application/json', 'accept': 'application/json'}
@@ -52,7 +34,7 @@
5234
verify=verify).json()
5335
for collection in collections:
5436
collectionID = collection['uuid']
55-
if collectionID not in skippedCollections:
37+
if collectionID not in skipColl:
5638
collectionIds.append(collectionID)
5739

5840
names = []

deleteBitstreamsFromItem.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,12 @@
55
import urllib3
66
import dsFunc
77

8-
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
9-
10-
secretsVersion = input('To edit production server, enter the name of the \
11-
secrets file: ')
12-
if secretsVersion != '':
13-
try:
14-
secrets = __import__(secretsVersion)
15-
print('Editing Production')
16-
except ImportError:
17-
secrets = __import__('secrets')
18-
print('Editing Development')
19-
else:
20-
secrets = __import__('secrets')
21-
print('Editing Development')
22-
23-
baseURL = secrets.baseURL
24-
email = secrets.email
25-
password = secrets.password
26-
filePath = secrets.filePath
27-
verify = secrets.verify
28-
skippedCollections = secrets.skippedCollections
8+
baseURL, email, password, filePath, verify, skipColl, sec = dsFunc.instSelect()
299

3010
itemHandle = input('Enter item handle: ')
3111

12+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
13+
3214
startTime = time.time()
3315
data = {'email': email, 'password': password}
3416
header = {'content-type': 'application/json', 'accept': 'application/json'}

deleteKeyFromCollection.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,7 @@
77
import argparse
88
import dsFunc
99

10-
secretsVersion = input('To edit production server, enter the name of the \
11-
secrets file: ')
12-
if secretsVersion != '':
13-
try:
14-
secrets = __import__(secretsVersion)
15-
print('Editing Production')
16-
except ImportError:
17-
secrets = __import__('secrets')
18-
print('Editing Development')
19-
else:
20-
secrets = __import__('secrets')
21-
print('Editing Development')
10+
baseURL, email, password, filePath, verify, skipColl, sec = dsFunc.instSelect()
2211

2312
parser = argparse.ArgumentParser()
2413
parser.add_argument('-k', '--deletedKey', help='the key to be deleted. \
@@ -39,13 +28,6 @@
3928

4029
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
4130

42-
baseURL = secrets.baseURL
43-
email = secrets.email
44-
password = secrets.password
45-
filePath = secrets.filePath
46-
verify = secrets.verify
47-
skippedCollections = secrets.skippedCollections
48-
4931
startTime = time.time()
5032
data = {'email': email, 'password': password}
5133
header = {'content-type': 'application/json', 'accept': 'application/json'}

deleteKeyFromCommunity.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,7 @@
77
import argparse
88
import dsFunc
99

10-
secretsVersion = input('To edit production server, enter the name of the \
11-
secrets file: ')
12-
if secretsVersion != '':
13-
try:
14-
secrets = __import__(secretsVersion)
15-
print('Editing Production')
16-
except ImportError:
17-
secrets = __import__('secrets')
18-
print('Editing Development')
19-
else:
20-
secrets = __import__('secrets')
21-
print('Editing Development')
10+
baseURL, email, password, filePath, verify, skipColl, sec = dsFunc.instSelect()
2211

2312
parser = argparse.ArgumentParser()
2413
parser.add_argument('-k', '--deletedKey', help='the key to be deleted. \
@@ -39,13 +28,6 @@
3928

4029
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
4130

42-
baseURL = secrets.baseURL
43-
email = secrets.email
44-
password = secrets.password
45-
filePath = secrets.filePath
46-
verify = secrets.verify
47-
skippedCollections = secrets.skippedCollections
48-
4931
startTime = time.time()
5032
data = {'email': email, 'password': password}
5133
header = {'content-type': 'application/json', 'accept': 'application/json'}

0 commit comments

Comments
 (0)