-
Notifications
You must be signed in to change notification settings - Fork 2
/
fileop.py
47 lines (41 loc) · 1.31 KB
/
fileop.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
# -*- coding: utf-8 -*-
# Falcon external file operator
# Copyright (C) 2019 Yukio Nozawa <[email protected]>
# Note: All comments except these top lines will be written in Japanese.
import logging
from logging import getLogger, FileHandler, Formatter
import sys
import traceback
import fileOperator
def main():
global log
log.info("Starting Falcon external file operation.")
if len(sys.argv) < 2:
log.error("No parameter specified.")
sys.exit(0)
# end error
file = sys.argv[1]
log.info("given:%s" % file)
o = fileOperator.FileOperator(file, elevated=True)
o.Execute()
log.info("End")
sys.exit(0)
def Onerror(type, exc, tb):
global log
log.error("crashed!")
for elem in traceback.format_exception(type, exc, tb):
log.error(elem.strip())
# end writing
sys.exit(0)
#global schope
if __name__ == "__main__":
hLogHandler = FileHandler("falconFOP.log", mode="w", encoding="UTF-8")
hLogHandler.setLevel(logging.DEBUG)
hLogFormatter = Formatter(
"%(name)s - %(levelname)s - %(message)s (%(asctime)s)")
hLogHandler.setFormatter(hLogFormatter)
log = getLogger("falcon")
log.setLevel(logging.DEBUG)
log.addHandler(hLogHandler)
sys.excepthook = Onerror
main()