-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
49 lines (39 loc) · 1.05 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
desktop_path = os.path.join(os.path.expanduser("~"), "Desktop")
update_script = '''
#!/bin/bash
cd ~/Desktop/MarioProject
clear
python3 main.py update
'''
process_script = '''
#!/bin/bash
cd ~/Desktop/MarioProject
clear
python3 main.py process
'''
def set_up_scripts():
"""
Sets up all scripts to run the program
:return:
None
"""
create_script(update_script, "Actualizar tablas.sh")
create_script(process_script, "Tablas de proceso.sh")
def create_script(script_text, name):
"""
Creates script for updating tables in the Desktop.
:arg
script_text (str): The script itself
name (str): Name of the script file *.sh
:return:
None
"""
script_path = os.path.join(desktop_path, name)
# If file exists, do nothing
if os.path.exists(script_path):
return
with open(script_path, 'w') as script_file:
script_file.write(script_text)
# Sets the executable permissions
os.chmod(script_path, 0o755)