-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot_app.py
31 lines (26 loc) · 947 Bytes
/
robot_app.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
class Application(object): ...
class AppBox(object):
def __init__(self) -> None:
self.app: Application = None
def setApp(self, app: Application) -> None:
try:
self.app = app
except RuntimeError as e:
raise e
def delApp(self) -> None:
self.app = None
def __bool__(self) -> bool:
return bool(self.app)
def cleanApp(appBox: AppBox, isAuto: bool=False):
if appBox:
try:
if not isAuto or (isAuto and not appBox.app.isAvailable):
print("Application {} is {}removed.".format(appBox.app.getName(), "automatically " if isAuto else ""))
appBox.delApp()
except RuntimeError as e:
try:
appName = appBox.app.getName()
except:
appName = ""
print("Application {} is removed due to exceptions: {}.".format(appName, e))
appBox.delApp()