-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathlog-remover.py
33 lines (25 loc) · 850 Bytes
/
log-remover.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
import tornado.ioloop
import tornado.web
import sys
import os
folder = "/var/lib/brand-server/cache/zip"
class MainHandler(tornado.web.RequestHandler):
def get(self):
list_of_files = os.listdir(folder)
counter = 0
for each_file in list_of_files:
real_path = os.path.join(folder, each_file)
if os.path.isfile(real_path):
os.remove(os.path.join(folder, each_file))
counter = counter + 1
self.write("removed: " + str(counter))
def make_app():
return tornado.web.Application([ (r"/", MainHandler), ])
if __name__ == "__main__":
if len(sys.argv)<3:
print("please specify the <port> and <zip folder>")
sys.exit(2)
app = make_app()
app.listen(sys.argv[1])
folder = sys.argv[2]
tornado.ioloop.IOLoop.current().start()