-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu-fail.py
168 lines (142 loc) · 4.03 KB
/
menu-fail.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#title :menu.py
#description :This program displays an interactive menu on CLI
#author :
#date :
#version :0.1
#usage :python menu.py
#notes :
#python_version :2.7.6
#=======================================================================
#qpy:2
#qpy:console
import re
import site
import sys, os
import datetime
import time
import calendar
from peewee import *
from glob import glob
today = datetime.datetime.today()
tomorrow = today + datetime.timedelta(days=1)
esok = tomorrow.strftime("%Y%m%d")
tahunini = datetime.datetime.today().year
bulanini = today.strftime("%Y%m")
# Main definition - constants
menu_actions = {}
# =======================
# MENUS FUNCTIONS
# =======================
# Main menu
def main_menu():
os.system('clear')
print ":: Hoye ::\n"
print "Sila pilih menu yang dikehendaki:"
print "1. Menu 1"
print "2. Menu 2"
print "3. Cari tarikh LP 2015"
print "\n0. Quit"
choice = raw_input(" >> ")
exec_menu(choice)
return
# Execute menu
def exec_menu(choice):
os.system('clear')
ch = choice.lower()
if ch == '':
menu_actions['main_menu']()
else:
try:
menu_actions[ch]()
except KeyError:
print "Invalid selection, please try again.\n"
menu_actions['main_menu']()
return
#-----------------------------------------------------------------------
def deletewhatsappdatabases():
selecteddir = '/storage/emulated/0/WhatsApp/Databases/'
for f in os.listdir(selecteddir):
print f
if re.search('msgstore-20(.*)crypt8'):
os.remove(os.path.join(selecteddir, f))
print "9. Back"
print "0. Quit"
choice = raw_input(" >> ")
exec_menu(choice)
return
def deletewordfiles():
selecteddir = '/storage/extSdCard/texdocs/wotd/'
for f in os.listdir(selecteddir):
print f
if re.search('wotd-20(.*).jpg'):
os.remove(os.path.join(selecteddir, f))
if re.search('wotd-20(.*).aux'):
os.remove(os.path.join(selecteddir, f))
if re.search('wotd-20(.*).log'):
os.remove(os.path.join(selecteddir, f))
if re.search('wotd-20(.*).pdf'):
os.remove(os.path.join(selecteddir, f))
if re.search('wotd-20(.*).pdf.jpg'):
os.remove(os.path.join(selecteddir, f))
print "9. Back"
print "0. Quit"
choice = raw_input(" >> ")
exec_menu(choice)
return
def deleteidiomfiles():
selecteddir = '/storage/extSdCard/texdocs/iotd/'
for f in os.listdir(selecteddir):
print f
if re.search('iotd-20(.*).jpg'):
os.remove(os.path.join(selecteddir, f))
if re.search('iotd-20(.*).aux'):
os.remove(os.path.join(selecteddir, f))
if re.search('iotd-20(.*).log'):
os.remove(os.path.join(selecteddir, f))
if re.search('iotd-20(.*).pdf'):
os.remove(os.path.join(selecteddir, f))
if re.search('iotd-20(.*).pdf.jpg'):
os.remove(os.path.join(selecteddir, f))
print "9. Back"
print "0. Quit"
choice = raw_input(" >> ")
exec_menu(choice)
return
def deleteenglishfiles():
deletewordfiles()
deleteidiomfiles()
def calendarview():
bulan = raw_input("\nMasukkan bulan [MM]: \n")
tahunini = int(datetime.datetime.now().year)
calendar.prmonth(tahunini, int(bulan))
print "9. Back"
print "0. Quit"
choice = raw_input(" >> ")
exec_menu(choice)
return
# Back to main menu
def back():
menu_actions['main_menu']()
# Exit program
def exit():
sys.exit()
# =======================
# MENUS DEFINITIONS
# =======================
# Menu definition
menu_actions = {
'cv': calendarview,
'dwd': deletewhatsappdatabases,
'def': deleteenglishfiles,
'9': back,
'q': exit,
}
# =======================
# MAIN PROGRAM
# =======================
# Main Program
if __name__ == "__main__":
# Launch main menu
main_menu()