File tree 1 file changed +0
-20
lines changed
1 file changed +0
-20
lines changed Original file line number Diff line number Diff line change 24
24
25
25
26
26
# Helper functions
27
- def backup_csv ():
28
- """Move all .csv files in the directory to a backup directory."""
29
- for file_name in os .listdir ():
30
- # We should only have one csv file, we back them up in a backup directory every time we run the program.
31
- if ".csv" in file_name :
32
- print ("There shouldn't be any .csv files in your directory. We found .csv files in your directory." )
33
- # We get the current working directory.
34
- directory = os .getcwd ()
35
- try :
36
- # We make a new directory called /backup
37
- os .mkdir (directory + "/backup/" )
38
- except :
39
- print ("Backup directory exists." )
40
- # Create a timestamp
41
- timestamp = datetime .now ()
42
- # We copy any .csv files in the folder to the backup folder.
43
- shutil .move (file_name , directory + "/backup/" + str (timestamp ) + "-" + file_name )
44
- print (f"Moved files to { directory } /backup directory." )
45
-
46
-
47
27
def in_sudo_mode ():
48
28
"""If the user doesn't run the program with super user privileges, don't allow them to continue."""
49
29
if not 'SUDO_UID' in os .environ .keys ():
You can’t perform that action at this time.
0 commit comments