|
24 | 24 |
|
25 | 25 |
|
26 | 26 | # Helper functions
|
27 |
| -defbackup_csv(): |
28 |
| -"""Move all .csv files in the directory to a backup directory.""" |
29 |
| -forfile_nameinos.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"infile_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 | defin_sudo_mode():
|
48 | 28 | """If the user doesn't run the program with super user privileges, don't allow them to continue."""
|
49 | 29 | ifnot'SUDO_UID'inos.environ.keys():
|
|