Skip to content

Commit 7e51bb5

Browse files
Merge pull request #19 from SynBioDex/no-login-fixes-branch
updated the functionality without logging in
2 parents 019aab7 + bfcc9ee commit 7e51bb5

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

.DS_Store

0 Bytes
Binary file not shown.

excelutils/.DS_Store

0 Bytes
Binary file not shown.

excelutils/excel_sbol_utils/library2.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@ def displayId(rowobj):
3838
if url.endswith('/'):
3939
url = url[:-1]
4040
collection = data["Library Name"]
41+
4142
master_collection = False
4243
private_collection = False
44+
if data["Domain"].strip() == "":
45+
# print("No domain name provided. Proceeding without checking displayId.")
46+
return
47+
4348
if is_url(collection) == False:
4449
private_collection = False
4550

@@ -67,7 +72,7 @@ def displayId(rowobj):
6772

6873
val = hf.check_name(val)
6974
# print("Display ID: ", val)
70-
75+
7176
if private_collection == True:
7277

7378
if username is None or password is None or url is None:
@@ -192,6 +197,7 @@ def definedFuncComponent(rowobj): #NOT IMPLEMENTED
192197
pass
193198

194199
def sequence_authentication(email, password, base_url,uri):
200+
195201
login_data = {
196202
'email': email,
197203
'password': password
@@ -260,6 +266,7 @@ def link_validation(email, password, base_url, target_url):
260266
'email': email,
261267
'password': password
262268
}
269+
263270
initial_response = requests.get(target_url, headers={'Accept': 'application/json'})
264271
# print("Initital response status code: ", initial_response.status_code)
265272
if initial_response.status_code == 200:
@@ -269,8 +276,11 @@ def link_validation(email, password, base_url, target_url):
269276
# the link is not accessible without authentication, try logging in
270277
elif initial_response.status_code in {401, 403, 404}:
271278
if email is None or password is None or base_url is None:
272-
# print("Need login credentials to access the link.")
273-
return False
279+
print(f"Need login credentials to access the link {target_url}.")
280+
print("This is a warning. XML file will NOT be generated.")
281+
os.environ["COUNTER"] = "Error found"
282+
# i just changed this to return True, but it was False
283+
return True
274284
else:
275285
login_response = requests.post(
276286
f"{base_url}/login",
@@ -764,15 +774,17 @@ def sequence(rowobj):
764774
username = os.getenv("SBOL_USERNAME")
765775
password = os.getenv("SBOL_PASSWORD")
766776
url = os.getenv("SBOL_URL")
767-
777+
dict = os.getenv("SBOL_DICTIONARY")
778+
data = json.loads(dict)
779+
768780
if isinstance(val, str):
769781
# might need to be careful if the object type is sequence!
770782
# THIS MIGHT HAVE BUGS IF MULTIPLE SEQUENCES ARE PROVIDED FOR
771783
# ONE OBJECT. E.g overwrite in self.obj.sequences = [val] ?
772784
if re.fullmatch(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', val):
773785
# if a url
774786
# rowobj.obj.sequences = [val]
775-
787+
776788
valid_uri = link_validation(username, password, url, val)
777789
if not valid_uri:
778790
print("Terminating")
@@ -788,6 +800,9 @@ def sequence(rowobj):
788800
val = val.replace(u"\ufeff", "").lower()
789801

790802
uri = f'{url}/search/sequence={val}&'
803+
if data["Domain"].strip() == "":
804+
# print("Domain not provided. Proceding without checking the domain for duplicate sequences.")
805+
return
791806
valid_uri = sequence_authentication(username, password, url,uri)
792807
if not valid_uri:
793808
print("Part name: ", rowobj.obj.identity.split('/')[-2])
@@ -823,6 +838,8 @@ def proteinSequence(rowobj):
823838
username = os.getenv("SBOL_USERNAME")
824839
password = os.getenv("SBOL_PASSWORD")
825840
url = os.getenv("SBOL_URL")
841+
dict = os.getenv("SBOL_DICTIONARY")
842+
data = json.loads(dict)
826843
if isinstance(val, str):
827844
# might need to be careful if the object type is sequence!
828845
# THIS MIGHT HAVE BUGS IF MULTIPLE SEQUENCES ARE PROVIDED FOR
@@ -847,6 +864,9 @@ def proteinSequence(rowobj):
847864
val = val.replace('*', '')
848865
val = val.replace(u"\ufeff", "").upper()
849866
uri = f'{url}/search/sequence={val}&'
867+
if data["Domain"].strip() == "":
868+
# print("Domain not provided. Proceding without checking the domain for duplicate sequences.")
869+
return
850870
valid_uri = sequence_authentication(username, password, url,uri)
851871
if not valid_uri:
852872
print("Part name: ", rowobj.obj.identity.split('/')[-2])

0 commit comments

Comments
 (0)