pymud 0.19.3.post2__py3-none-any.whl → 0.20.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pymud/__init__.py CHANGED
@@ -1,8 +1,12 @@
1
1
  from .settings import Settings
2
+ from .pymud import PyMudApp
3
+ from .modules import IConfig
2
4
  from .objects import CodeBlock, Alias, SimpleAlias, Trigger, SimpleTrigger, Command, SimpleCommand, Timer, SimpleTimer, GMCPTrigger
3
5
  from .extras import DotDict
4
6
  from .session import Session
7
+ from .logger import Logger
8
+ from .main import main
5
9
 
6
10
  __all__ = [
7
- "Settings", "CodeBlock", "Alias", "SimpleAlias", "Trigger", "SimpleTrigger", "Command", "SimpleCommand", "Timer", "SimpleTimer", "GMCPTrigger", "Session", "PyMudApp", "DotDict"
11
+ "IConfig", "PyMudApp", "Settings", "CodeBlock", "Alias", "SimpleAlias", "Trigger", "SimpleTrigger", "Command", "SimpleCommand", "Timer", "SimpleTimer", "GMCPTrigger", "Session", "PyMudApp", "DotDict", "Logger", "main"
8
12
  ]
pymud/__main__.py CHANGED
@@ -1,102 +1,4 @@
1
- import sys, os, json, platform, shutil, logging
2
- from .pymud import main
3
- from .settings import Settings
4
-
5
- CFG_TEMPLATE = {
6
- "client": {
7
- "buffer_lines" : 5000, # 保留缓冲行数
8
-
9
- "interval" : 10, # 在自动执行中,两次命令输入中的间隔时间(ms)
10
- "auto_connect" : True, # 创建会话后,是否自动连接
11
- "auto_reconnect" : False, # 在会话异常断开之后,是否自动重连
12
- "var_autosave" : True, # 断开时自动保存会话变量
13
- "var_autoload" : True, # 初始化时自动加载会话变量
14
-
15
- "echo_input" : False,
16
- "beautify" : True, # 专门为解决控制台下PKUXKX字符画对不齐的问题
17
-
18
- "status_display" : 1, # 状态窗口显示情况设置,0-不显示,1-显示在下方,2-显示在右侧
19
- "status_height" : 4, # 下侧状态栏的高度
20
- "status_width" : 30, # 右侧状态栏的宽度
21
-
22
- },
23
- "sessions" : {
24
- "pkuxkx" : {
25
- "host" : "mud.pkuxkx.net",
26
- "port" : "8081",
27
- "encoding" : "utf8",
28
- "autologin" : "{0};{1}",
29
- "default_script": "examples",
30
- "chars" : {
31
- "display_title" : ["yourid", "yourpassword", ""],
32
- }
33
- }
34
- },
35
- "keys" : {
36
- "f3" : "#ig",
37
- "f4" : "#clear",
38
- "f11" : "#close",
39
- "f12" : "#exit",
40
- }
41
- }
1
+ from .main import main
42
2
 
43
3
  if __name__ == "__main__":
44
- args = sys.argv
45
- if (len(args) == 2) and (args[1] == "init"):
46
- print(f"欢迎使用PyMUD, 版本{Settings.__version__}. 使用PyMUD时, 建议建立一个新目录(任意位置),并将自己的脚本以及配置文件放到该目录下.")
47
- print("即将开始为首次运行初始化环境...")
48
- uname = platform.uname()
49
- system = uname[0].lower()
50
- if system == "windows":
51
- dir = input("检测到当前系统为Windows, 请指定游戏脚本的目录(若目录不存在会自动创建),直接回车表示使用默认值[d:\pkuxkx\]:")
52
- if not dir: dir = "d:\\pkuxkx\\"
53
- elif system == "linux":
54
- dir = input("检测到当前系统为Linux, 请指定游戏脚本的目录(若目录不存在会自动创建),直接回车表示使用默认值[~/pkuxkx/]:")
55
- if not dir: dir = "~/pkuxkx/"
56
-
57
- if not os.path.exists(dir):
58
- print(f'检测到给定目录 {dir} 不存在,正在创建目录...', end = "")
59
- os.mkdir(dir)
60
- os.chdir(dir)
61
- print(f'完成!')
62
-
63
- if os.path.exists('pymud.cfg'):
64
- print(f'检测到脚本目录下已存在pymud.cfg文件,将直接使用此文件进入PyMUD...')
65
- else:
66
- print(f'检测到脚本目录下不存在pymud.cfg文件,将使用默认内容创建该配置文件...')
67
- with open('pymud.cfg', mode = 'x') as fp:
68
- fp.writelines(json.dumps(CFG_TEMPLATE, indent = 4))
69
-
70
- if not os.path.exists('examples.py'):
71
- from pymud import pkuxkx
72
- module_dir = pkuxkx.__file__
73
- shutil.copyfile(module_dir, 'examples.py')
74
- print(f'已将样例脚本拷贝至脚本目录,并加入默认配置文件')
75
-
76
- print(f"后续可自行修改 {dir} 目录下的 pymud.cfg 文件以进行配置。")
77
- if system == "linux":
78
- print(f"后续运行PyMUD, 请在 {dir} 目录下键入命令: python3 -m pymud")
79
- else:
80
- print(f"后续运行PyMUD, 请在 {dir} 目录下键入命令: python -m pymud")
81
-
82
- input('所有内容已初始化完毕, 请按回车进入PyMUD.')
83
-
84
- if (len(args) == 2) and (args[1] == "withlog"):
85
- # 指定带log时,打印log信息
86
- # 所有级别log都存入文件
87
- logging.basicConfig(level=logging.NOTSET,
88
- format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
89
- datefmt='%m-%d %H:%M',
90
- filename='myapp.log',
91
- filemode='a')
92
-
93
- else:
94
- logging.disable()
95
-
96
- cfg = "pymud.cfg"
97
- if os.path.exists(cfg):
98
- with open(cfg, "r", encoding="utf8", errors="ignore") as fp:
99
- cfg_data = json.load(fp)
100
- main(cfg_data)
101
- else:
102
- main()
4
+ main()
pymud/dialogs.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import asyncio, webbrowser
2
2
 
3
3
  from prompt_toolkit.layout import AnyContainer, ConditionalContainer, Float, VSplit, HSplit, Window, WindowAlign, ScrollablePane, ScrollOffsets
4
- from prompt_toolkit.widgets import Button, Dialog, Label, MenuContainer, MenuItem, TextArea, SystemToolbar, Frame
4
+ from prompt_toolkit.widgets import Button, Dialog, Label, MenuContainer, MenuItem, TextArea, SystemToolbar, Frame, RadioList
5
5
  from prompt_toolkit.layout.dimension import Dimension, D
6
6
  from prompt_toolkit import ANSI, HTML
7
7
  from prompt_toolkit.mouse_events import MouseEvent, MouseEventType
@@ -127,3 +127,35 @@ class NewSessionDialog(BasicDialog):
127
127
  encoding = get_app().layout.get_buffer_by_name("encoding").text
128
128
  result = (name, host, port, encoding)
129
129
  self.set_done(result)
130
+
131
+
132
+ class LogSelectionDialog(BasicDialog):
133
+ def __init__(self, text, values, modal=True):
134
+ self._header_text = text
135
+ self._selection_values = values
136
+ self._itemsCount = len(values)
137
+ if len(values) > 0:
138
+ self._radio_list = RadioList(values = self._selection_values)
139
+ else:
140
+ self._radio_list = Label('无记录'.center(13))
141
+ super().__init__('选择查看的记录', modal)
142
+
143
+ def create_body(self) -> AnyContainer:
144
+ body=HSplit([
145
+ Label(text = self._header_text, dont_extend_height=True),
146
+ self._radio_list
147
+ ])
148
+ return body
149
+
150
+ def create_buttons(self):
151
+ ok_button = EasternButton(text="确定", handler=self.btn_ok_clicked)
152
+ cancel_button = EasternButton(text="取消", handler=(lambda: self.set_done(False)))
153
+ return [ok_button, cancel_button]
154
+
155
+ def btn_ok_clicked(self):
156
+ if self._itemsCount:
157
+ result = self._radio_list.current_value
158
+ self.set_done(result)
159
+ else:
160
+ self.set_done(False)
161
+
pymud/extras.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # External Libraries
2
2
  from unicodedata import east_asian_width
3
3
  from wcwidth import wcwidth
4
- from typing import Any
5
4
  import time
6
5
 
7
6
  from typing import Iterable
@@ -434,6 +433,7 @@ class SessionBufferControl(BufferControl):
434
433
  buffer.cursor_position = start
435
434
  buffer.start_selection(selection_type=SelectionType.CHARACTERS)
436
435
  buffer.cursor_position = end
436
+
437
437
  else:
438
438
  # Don't handle scroll events here.
439
439
  return NotImplemented
@@ -1007,75 +1007,5 @@ class DotDict(dict):
1007
1007
  def __setstate__(self, state):
1008
1008
  self.update(state)
1009
1009
 
1010
- import importlib
1011
- import importlib.util
1012
-
1013
- class Plugin:
1014
- """
1015
- 插件管理类。对加载的插件文件进行管理。该类型由PyMudApp进行管理,无需人工创建。
1016
-
1017
- 有关插件的详细信息,请参见 `插件 <plugins.html>`_
1018
-
1019
- :param name: 插件的文件名, 如'myplugin.py'
1020
- :param location: 插件所在的目录。自动加载的插件包括PyMUD包目录下的plugins目录以及当前目录下的plugins目录
1021
-
1022
- """
1023
- def __init__(self, name, location):
1024
- self._plugin_file = name
1025
- self._plugin_loc = location
1026
-
1027
- self.reload()
1028
-
1029
- def reload(self):
1030
- "加载/重新加载插件对象"
1031
- #del self.modspec, self.mod
1032
- self.modspec = importlib.util.spec_from_file_location(self._plugin_file[:-3], self._plugin_loc)
1033
- self.mod = importlib.util.module_from_spec(self.modspec)
1034
- self.modspec.loader.exec_module(self.mod)
1035
-
1036
- self._app_init = self.mod.__dict__["PLUGIN_PYMUD_START"]
1037
- self._session_create = self.mod.__dict__["PLUGIN_SESSION_CREATE"]
1038
- self._session_destroy = self.mod.__dict__["PLUGIN_SESSION_DESTROY"]
1039
-
1040
- @property
1041
- def name(self):
1042
- "插件名称,由插件文件中的 PLUGIN_NAME 常量定义"
1043
- return self.mod.__dict__["PLUGIN_NAME"]
1044
-
1045
- @property
1046
- def desc(self):
1047
- "插件描述,由插件文件中的 PLUGIN_DESC 常量定义"
1048
- return self.mod.__dict__["PLUGIN_DESC"]
1049
-
1050
- @property
1051
- def help(self):
1052
- "插件帮助,由插件文件中的文档字符串定义"
1053
- return self.mod.__doc__
1054
-
1055
- def onAppInit(self, app):
1056
- """
1057
- PyMUD应用启动时对插件执行的操作,由插件文件中的 PLUGIN_PYMUD_START 函数定义
1058
-
1059
- :param app: 启动的 PyMudApp 对象实例
1060
- """
1061
- self._app_init(app)
1062
-
1063
- def onSessionCreate(self, session):
1064
- """
1065
- 新会话创建时对插件执行的操作,由插件文件中的 PLUGIN_SESSION_CREATE 函数定义
1066
-
1067
- :param session: 新创建的会话对象实例
1068
- """
1069
- self._session_create(session)
1070
-
1071
- def onSessionDestroy(self, session):
1072
- """
1073
- 会话关闭时(注意不是断开)对插件执行的操作,由插件文件中的 PLUGIN_SESSION_DESTROY 函数定义
1074
-
1075
- :param session: 所关闭的会话对象实例
1076
- """
1077
- self._session_destroy(session)
1078
1010
 
1079
- def __getattr__(self, __name: str) -> Any:
1080
- if hasattr(self.mod, __name):
1081
- return self.mod.__getattribute__(__name)
1011
+
pymud/logger.py ADDED
@@ -0,0 +1,160 @@
1
+ import os, re, datetime, threading, pathlib
2
+ from queue import SimpleQueue, Empty
3
+ from pathlib import Path
4
+
5
+ class Logger:
6
+ """
7
+ PyMUD 的记录器类型,可用于会话中向文件记录数据。记录文件保存在当前目录下的 log 子目录中
8
+
9
+ :param name: 记录器名称,各记录器名称应保持唯一。记录器名称会作为记录文件名称的主要参数
10
+ :param mode: 记录模式。可选模式包括 a, w, n 三种。
11
+ - a为添加模式,当新开始记录时,会添加在原有记录文件(name.log)之后。
12
+ - w为覆写模式,当新开始记录时,会覆写原记录文件(name.log)。
13
+ - n为新建模式,当新开始记录时,会以name和当前时间为参数新建一个文件(name.now.log)用于记录。
14
+ :param encoding: 记录文件的编码格式,默认为 "utf-8"
15
+ :param errors: 当编码模式失败时的处理方式,默认为 "ignore"
16
+ :param raw: 记录带ANSI标记的原始内容,还是记录纯文本内容,默认为True,即记录带ANSI标记的原始内容。
17
+ """
18
+
19
+ _esc_regx = re.compile(r"\x1b\[[\d;]+[abcdmz]", flags = re.IGNORECASE)
20
+
21
+ def __init__(self, name, mode = 'a', encoding = "utf-8", errors = "ignore", raw = False):
22
+ self._name = name
23
+ self._enabled = False
24
+ self._raw = raw
25
+ self.mode = mode
26
+ self._encoding = encoding
27
+ self._errors = errors
28
+ self._lock = threading.RLock()
29
+ self._stream = None
30
+
31
+ self._queue = SimpleQueue()
32
+
33
+ @property
34
+ def name(self):
35
+ "记录器名称,仅在创建时设置,过程中只读"
36
+ return self._name
37
+
38
+ @property
39
+ def enabled(self):
40
+ """
41
+ 使能属性。
42
+ 从false切换到true时,会打开文件,创建后台线程进行记录。
43
+ 从true切换到false时,会终止后台记录线程,并关闭记录文件。
44
+ """
45
+ return self._enabled
46
+
47
+ @enabled.setter
48
+ def enabled(self, enabled):
49
+ if self._enabled != enabled:
50
+ if enabled:
51
+ mode = "a"
52
+
53
+ if self._mode in ("a", "w"):
54
+ filename = f"{self.name}.log"
55
+ mode = self._mode
56
+ elif self._mode == "n":
57
+ now = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
58
+ filename = f"{self.name}.{now}.log"
59
+
60
+ logdir = Path.cwd().joinpath('log')
61
+ if not logdir.exists() or not logdir.is_dir():
62
+ logdir.mkdir()
63
+
64
+ filename = logdir.joinpath(filename)
65
+ #filename = os.path.abspath(filename)
66
+ self._stream = open(filename, mode = mode, encoding = self._encoding, errors = self._errors)
67
+ self._thread = t = threading.Thread(target=self._monitor)
68
+ t.daemon = True
69
+ t.start()
70
+
71
+ else:
72
+ self._queue.put_nowait(None)
73
+ self._thread.join()
74
+ self._thread = None
75
+ self._closeFile()
76
+
77
+ self._enabled = enabled
78
+
79
+ @property
80
+ def raw(self):
81
+ "属性,设置和获取是否记录带有ANSI标记的原始记录"
82
+ return self._raw
83
+
84
+ @raw.setter
85
+ def raw(self, val: bool):
86
+ self._raw = val
87
+
88
+ @property
89
+ def mode(self):
90
+ "属性,记录器模式,可为 a, w, n"
91
+ return self._mode
92
+
93
+ @mode.setter
94
+ def mode(self, value):
95
+ if value in ("a", "w", "n"):
96
+ self._mode = value
97
+
98
+ def _closeFile(self):
99
+ """
100
+ Closes the stream.
101
+ """
102
+ self._lock.acquire()
103
+ try:
104
+ if self._stream:
105
+ try:
106
+ self._stream.flush()
107
+ finally:
108
+ stream = self._stream
109
+ self._stream = None
110
+ stream.close()
111
+ finally:
112
+ self._lock.release()
113
+
114
+ def log(self, msg):
115
+ """
116
+ 向记录器记录信息。记录的信息会通过队列发送到独立的记录线程。
117
+ 当记录器未使能时,使用该函数调用也不会记录。
118
+
119
+ :param msg: 要记录的信息
120
+ """
121
+ if self._enabled:
122
+ self._queue.put_nowait(msg)
123
+
124
+ def _monitor(self):
125
+ """
126
+ Monitor the queue for records, and ask the handler
127
+ to deal with them.
128
+
129
+ This method runs on a separate, internal thread.
130
+ The thread will terminate if it sees a sentinel object in the queue.
131
+ """
132
+ newline = True
133
+ while True:
134
+ try:
135
+ data = self._queue.get(block = True)
136
+ if data:
137
+ self._lock.acquire()
138
+
139
+ if newline:
140
+ now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
141
+ header = f"{now} {self._name}: "
142
+ self._stream.write(header)
143
+ newline = False
144
+
145
+ if data.endswith("\n"):
146
+ data = data.rstrip("\n").rstrip("\r") + "\n"
147
+ newline = True
148
+
149
+ if not self._raw:
150
+ data = self._esc_regx.sub("", data)
151
+
152
+ self._stream.write(data)
153
+
154
+ self._stream.flush()
155
+ self._lock.release()
156
+
157
+ else:
158
+ break
159
+ except Empty:
160
+ break
pymud/main.py ADDED
@@ -0,0 +1,142 @@
1
+ import os, sys, json, platform, shutil, logging, argparse
2
+ from pathlib import Path
3
+ from .pymud import PyMudApp
4
+ from .settings import Settings
5
+
6
+ CFG_TEMPLATE = {
7
+ "client": {
8
+ "buffer_lines" : 5000, # 保留缓冲行数
9
+
10
+ "interval" : 10, # 在自动执行中,两次命令输入中的间隔时间(ms)
11
+ "auto_connect" : True, # 创建会话后,是否自动连接
12
+ "auto_reconnect" : False, # 在会话异常断开之后,是否自动重连
13
+ "var_autosave" : True, # 断开时自动保存会话变量
14
+ "var_autoload" : True, # 初始化时自动加载会话变量
15
+
16
+ "echo_input" : False,
17
+ "beautify" : True, # 专门为解决控制台下PKUXKX字符画对不齐的问题
18
+
19
+ "status_display" : 1, # 状态窗口显示情况设置,0-不显示,1-显示在下方,2-显示在右侧
20
+ "status_height" : 4, # 下侧状态栏的高度
21
+ "status_width" : 30, # 右侧状态栏的宽度
22
+
23
+ },
24
+ "sessions" : {
25
+ "pkuxkx" : {
26
+ "host" : "mud.pkuxkx.net",
27
+ "port" : "8081",
28
+ "encoding" : "utf8",
29
+ "autologin" : "{0};{1}",
30
+ "default_script": "examples",
31
+ "chars" : {
32
+ "display_title" : ["yourid", "yourpassword", ""],
33
+ }
34
+ }
35
+ },
36
+ "keys" : {
37
+ "f3" : "#ig",
38
+ "f4" : "#clear",
39
+ "f11" : "#close",
40
+ "f12" : "#exit",
41
+ }
42
+ }
43
+
44
+ def init_pymud_env(args):
45
+ print(f"欢迎使用PyMUD, 版本{Settings.__version__}. 使用PyMUD时, 建议建立一个新目录(任意位置),并将自己的脚本以及配置文件放到该目录下.")
46
+ print("即将开始为首次运行初始化环境...")
47
+
48
+ dir = args.dir
49
+ if dir:
50
+ print(f"你已经指定了创建脚本的目录为 {args.dir}")
51
+ dir = Path(dir)
52
+ else:
53
+ dir = Path.home().joinpath('pkuxkx')
54
+
55
+ system = platform.system().lower()
56
+ dir_enter = input(f"检测到当前系统为 {system}, 请指定游戏脚本的目录(若目录不存在会自动创建),直接回车表示使用默认值 [{dir}]:")
57
+ if dir_enter:
58
+ dir = Path(dir_enter)
59
+
60
+ if dir.exists() and dir.is_dir():
61
+ print(f'检测到给定目录 {dir} 已存在,切换至此目录...')
62
+ else:
63
+ print(f'检测到给定目录 {dir} 不存在,正在创建并切换至目录...')
64
+ dir.mkdir()
65
+
66
+ os.chdir(dir)
67
+
68
+ if os.path.exists('pymud.cfg'):
69
+ print(f'检测到脚本目录下已存在pymud.cfg文件,将直接使用此文件进入PyMUD...')
70
+ else:
71
+ print(f'检测到脚本目录下不存在pymud.cfg文件,将使用默认内容创建该配置文件...')
72
+ with open('pymud.cfg', mode = 'x') as fp:
73
+ fp.writelines(json.dumps(CFG_TEMPLATE, indent = 4))
74
+
75
+ if not os.path.exists('examples.py'):
76
+ from pymud import pkuxkx
77
+ module_dir = pkuxkx.__file__
78
+ shutil.copyfile(module_dir, 'examples.py')
79
+ print(f'已将样例脚本拷贝至脚本目录,并加入默认配置文件')
80
+
81
+ print(f"后续可自行修改 {dir} 目录下的 pymud.cfg 文件以进行配置。")
82
+ if system == "windows":
83
+ print(f"后续运行PyMUD, 请在 {dir} 目录下键入命令: python -m pymud")
84
+ else:
85
+ print(f"后续运行PyMUD, 请在 {dir} 目录下键入命令: python3 -m pymud")
86
+
87
+ input('所有内容已初始化完毕, 请按回车进入PyMUD.')
88
+
89
+ startApp(args)
90
+
91
+ def startApp(args):
92
+ startup_path = Path(args.startup_dir).resolve()
93
+ sys.path.append(f"{startup_path}")
94
+ os.chdir(startup_path)
95
+
96
+ if args.debug:
97
+ logging.basicConfig(level = logging.NOTSET,
98
+ format = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
99
+ datefmt = '%m-%d %H:%M',
100
+ filename = args.logfile,
101
+ filemode = 'a' if args.filemode else 'w',
102
+ encoding = "utf-8"
103
+ )
104
+
105
+ else:
106
+ logging.basicConfig(level = logging.NOTSET,
107
+ format = '%(asctime)s %(name)-12s: %(message)s',
108
+ datefmt = '%m-%d %H:%M',
109
+ handlers = [logging.NullHandler()],
110
+ )
111
+
112
+ cfg = startup_path.joinpath("pymud.cfg")
113
+ cfg_data = None
114
+ if os.path.exists(cfg):
115
+ with open(cfg, "r", encoding="utf8", errors="ignore") as fp:
116
+ cfg_data = json.load(fp)
117
+
118
+ app = PyMudApp(cfg_data)
119
+ app.run()
120
+
121
+ def main():
122
+ parser = argparse.ArgumentParser(prog = "pymud", description = "PyMUD命令行参数帮助")
123
+ subparsers = parser.add_subparsers(help = 'init用于初始化运行环境')
124
+
125
+ par_init = subparsers.add_parser('init', description = '初始化pymud运行环境, 包括建立脚本目录, 创建默认配置文件, 创建样例脚本等.')
126
+ par_init.add_argument('-d', '--dir', dest = 'dir', metavar = 'dir', type = str, default = '', help = '指定构建脚本目录的名称, 不指定时会根据操作系统选择不同默认值')
127
+ par_init.set_defaults(func = init_pymud_env)
128
+
129
+ parser.add_argument('-d', '--debug', dest = 'debug', action = 'store_true', default = False, help = '指定以调试模式进入PyMUD。此时,系统log等级将设置为logging.NOTSET, 所有log数据均会被记录。默认不启用。')
130
+ parser.add_argument('-l', '--logfile', dest = 'logfile', metavar = 'logfile', default = 'pymud.log', help = '指定调试模式下记录文件名,不指定时,默认为当前目录下的pymud.log')
131
+ parser.add_argument('-a', '--appendmode', dest = 'filemode', action = 'store_true', default = True, help = '指定log文件的访问模式是否为append尾部添加模式,默认为True。当为False时,使用w模式,即每次运行清空之前记录')
132
+ parser.add_argument('-s', '--startup_dir', dest = 'startup_dir', metavar = 'startup_dir', default = '.', help = '指定启动目录,默认为当前目录。使用该参数可以在任何目录下,通过指定脚本目录来启动')
133
+
134
+ args=parser.parse_args()
135
+
136
+ if hasattr(args, 'func'):
137
+ args.func(args)
138
+ else:
139
+ startApp(args)
140
+
141
+ if __name__ == "__main__":
142
+ main()