-
Notifications
You must be signed in to change notification settings - Fork 0
/
TaskScheduler.py
74 lines (54 loc) · 1.89 KB
/
TaskScheduler.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
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Adolfo.Diaz
#
# Created: 06/01/2022
# Copyright: (c) Adolfo.Diaz 2022
# Licence: <your licence>
#-------------------------------------------------------------------------------
## ===================================================================================
def AddMsgAndPrint(msg, severity=0):
# prints message to screen if run as a python script
# Adds tool message to the geoprocessor
#
#Split the message on \n first, so that if it's multiple lines, a GPMessage will be added for each line
try:
print(msg)
#print msg
f = open(textFilePath,'a+')
f.write(msg + " \n")
f.close
del f
except:
pass
## ===================================================================================
def errorMsg():
try:
exc_type, exc_value, exc_traceback = sys.exc_info()
theMsg = "\t" + traceback.format_exception(exc_type, exc_value, exc_traceback)[1] + "\n\t" + traceback.format_exception(exc_type, exc_value, exc_traceback)[-1]
if theMsg.find("exit") > -1:
AddMsgAndPrint("\n\n")
pass
else:
AddMsgAndPrint(theMsg)
except:
AddMsgAndPrint("Unhandled error in unHandledException method", 2)
pass
import os
from urllib.error import HTTPError, URLError
from urllib.request import Request
if __name__ == '__main__':
try:
folder = r'N:\scratch'
existingDir = os.listdir(folder)
textFilePath = folder + os.sep + "Test_logFile.txt"
i = 0
while i < 5:
os.mkdir(os.path.join(folder,"Test" + str(i)))
AddMsgAndPrint(f"Creating Folder# {i}")
#AddMsgAndPrint("Creating Folder# " + str(i))
i+=1
except:
errorMsg()