55from .md_to_json import parse_readme_to_json
66import json
77import os
8- #import configparser
8+
9+ # import configparser
910from cryptography .fernet import Fernet
1011
1112CALTECHDATA_API = "https://data.caltech.edu/api/names?q=identifiers.identifier:{}"
2324funderName = ""
2425
2526
26- #CONFIG_FILE = "caltechdata_config.ini"
27+ # CONFIG_FILE = "caltechdata_config.ini"
2728
2829
2930home_directory = os .path .expanduser ("~" )
3334if not os .path .exists (caltechdata_directory ):
3435 os .makedirs (caltechdata_directory )
3536
37+
3638def generate_key ():
3739 return Fernet .generate_key ()
3840
41+
3942# Load the key from a file or generate a new one if not present
4043def load_or_generate_key (key_file = "key.key" ):
4144 if os .path .exists (key_file ):
@@ -47,19 +50,21 @@ def load_or_generate_key(key_file="key.key"):
4750 f .write (key )
4851 return key
4952
53+
5054# Encrypt the token
5155def encrypt_token (token , key ):
5256 f = Fernet (key )
5357 return f .encrypt (token .encode ())
5458
59+
5560# Decrypt the token
5661def decrypt_token (encrypted_token , key ):
5762 f = Fernet (key )
5863 return f .decrypt (encrypted_token ).decode ()
5964
65+
6066# Function to get or set token
6167def get_or_set_token ():
62-
6368 key = load_or_generate_key ()
6469 try :
6570 with open ("token.txt" , "rb" ) as f :
@@ -77,7 +82,8 @@ def get_or_set_token():
7782 return token
7883 else :
7984 print ("Tokens do not match. Please try again." )
80-
85+
86+
8187def welcome_message ():
8288 print ("Welcome to CaltechDATA CLI" )
8389
@@ -261,8 +267,12 @@ def upload_supporting_file(record_id=None):
261267 path = "ini230004-bucket01/"
262268
263269 if not record_id :
264- record_id = get_user_input ("Folder where OSN files are uploaded" )
265-
270+ print (
271+ """Please upload the
272+ metadata to CaltechDATA, and you'll be provided
273+ instructions to upload the files to S3 directly."""
274+ )
275+ break
266276 s3 = s3fs .S3FileSystem (anon = True , client_kwargs = {"endpoint_url" : endpoint })
267277 # Find the files
268278 files = s3 .glob (path + record_id + "/*" )
@@ -306,11 +316,11 @@ def upload_supporting_file(record_id=None):
306316 if filename in files :
307317 file_size = os .path .getsize (filename )
308318 if file_size > 1024 * 1024 * 1024 :
309- file_link = get_user_input (
310- "Enter the S3 link to the file (File size is more than 1GB): "
319+ print (
320+ """The file is greater than 1 GB. Please upload the
321+ metadata to CaltechDATA, and you'll be provided
322+ instructions to upload the files to S3 directly."""
311323 )
312- if file_link :
313- file_links .append (file_link )
314324 else :
315325 filepath = os .path .abspath (filename )
316326 filepaths .append (filepath )
@@ -330,6 +340,7 @@ def upload_supporting_file(record_id=None):
330340
331341 return filepaths , file_links
332342
343+
333344def upload_data_from_file ():
334345 while True :
335346 print ("Current JSON files in the directory:" )
@@ -511,7 +522,11 @@ def edit_record():
511522 )
512523 rec_id = response
513524 print (
514- f"You can view and publish this record at https://data.caltechlibrary.dev/uploads/{ rec_id } "
525+ f"""You can view and publish this record at
526+ https://data.caltechlibrary.dev/uploads/{ rec_id } \n
527+ If you need to upload large files to S3, you can type `s3cmd
528+ --endpoint-url https://renc.osn.xsede.org:443 cp DATA_FILE
529+ s3://ini210004tommorrell/{ rec_id } """
515530 )
516531
517532
0 commit comments