tina4-python 0.1.98__tar.gz → 0.2.1__tar.gz

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.
Files changed (39) hide show
  1. {tina4_python-0.1.98 → tina4_python-0.2.1}/PKG-INFO +1 -1
  2. {tina4_python-0.1.98 → tina4_python-0.2.1}/pyproject.toml +1 -1
  3. tina4_python-0.2.1/tina4_python/__init__.py +224 -0
  4. tina4_python-0.1.98/tina4_python/__init__.py +0 -223
  5. {tina4_python-0.1.98 → tina4_python-0.2.1}/README.md +0 -0
  6. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Auth.py +0 -0
  7. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Constant.py +0 -0
  8. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Database.py +0 -0
  9. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/DatabaseResult.py +0 -0
  10. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Debug.py +0 -0
  11. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Env.py +0 -0
  12. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Localization.py +0 -0
  13. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Messages.py +0 -0
  14. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Migration.py +0 -0
  15. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Request.py +0 -0
  16. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Response.py +0 -0
  17. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Router.py +0 -0
  18. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Session.py +0 -0
  19. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/ShellColors.py +0 -0
  20. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Swagger.py +0 -0
  21. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Template.py +0 -0
  22. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/Webserver.py +0 -0
  23. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/messages.pot +0 -0
  24. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/public/css/readme.md +0 -0
  25. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/public/favicon.ico +0 -0
  26. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/public/images/403.png +0 -0
  27. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/public/images/404.png +0 -0
  28. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/public/images/logo.png +0 -0
  29. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/public/images/readme.md +0 -0
  30. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/public/js/readme.md +0 -0
  31. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/public/swagger/index.html +0 -0
  32. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
  33. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/templates/errors/403.twig +0 -0
  34. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/templates/errors/404.twig +0 -0
  35. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/templates/readme.md +0 -0
  36. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
  37. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
  38. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
  39. {tina4_python-0.1.98 → tina4_python-0.2.1}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tina4-python
3
- Version: 0.1.98
3
+ Version: 0.2.1
4
4
  Summary: Tina4Python - This is not another framework for Python
5
5
  Author: Andre van Zuydam
6
6
  Author-email: andrevanzuydam@gmail.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tina4-python"
3
- version = "0.1.98"
3
+ version = "0.2.1"
4
4
  description = "Tina4Python - This is not another framework for Python"
5
5
  authors = ["Andre van Zuydam <andrevanzuydam@gmail.com>"]
6
6
  readme = "README.md"
@@ -0,0 +1,224 @@
1
+ #
2
+ # Tina4 - This is not a 4ramework.
3
+ # Copy-right 2007 - current Tina4
4
+ # License: MIT https://opensource.org/licenses/MIT
5
+ #
6
+ # flake8: noqa: E403,F401,E402
7
+ import asyncio
8
+ import gettext
9
+ import os
10
+ import shutil
11
+ import importlib
12
+ import sys
13
+ import sass
14
+ from pathlib import Path
15
+ from watchdog.observers import Observer
16
+ from watchdog.events import FileSystemEventHandler, FileSystemEvent
17
+
18
+ from tina4_python.Router import get
19
+ from tina4_python import Messages, Constant
20
+ from tina4_python.Swagger import Swagger
21
+ from tina4_python.Env import load_env
22
+ from tina4_python.Webserver import Webserver
23
+ from tina4_python.Router import Router, get
24
+ from tina4_python.Localization import localize
25
+ from tina4_python.Auth import Auth
26
+ from tina4_python.Debug import Debug
27
+ from tina4_python.ShellColors import ShellColors
28
+
29
+ _ = gettext.gettext
30
+
31
+ # Server startup messages
32
+ MSG_ASSUMING_ROOT_PATH = _('Assuming root path: {root_path}, library path: {library_path}')
33
+ MSG_LOAD_ALL_THINGS = _('Load all things')
34
+ MSG_SERVER_STARTED = _('Server started http://{host_name}:{port}')
35
+ MSG_SERVER_STOPPED = _('Server stopped.')
36
+ MSG_STARTING_WEBSERVER = _('Starting webserver on {port}')
37
+ MSG_ENTRY_POINT_NAME = _('Entry point name ... {name}')
38
+
39
+ if os.getenv('environment') is not None:
40
+ environment = ".env." + os.getenv('environment')
41
+ else:
42
+ environment = ".env"
43
+
44
+ load_env(environment)
45
+
46
+ print(ShellColors.bright_yellow + "Setting debug mode", os.getenv("TINA4_DEBUG_LEVEL"), ShellColors.end)
47
+ localize()
48
+
49
+ if importlib.util.find_spec("jurigged"):
50
+ import jurigged
51
+
52
+ # Define the variable to be used for global routes
53
+ library_path = os.path.dirname(os.path.realpath(__file__))
54
+ root_path = os.path.realpath(os.getcwd())
55
+ Debug(Messages.MSG_ASSUMING_ROOT_PATH.format(root_path=root_path, library_path=library_path),
56
+ Constant.TINA4_LOG_INFO)
57
+
58
+
59
+ tina4_routes = {}
60
+ tina4_current_request = {}
61
+ tina4_secret = None
62
+ tina4_auth = Auth(root_path)
63
+
64
+ token = tina4_auth.get_token({"name": "Tina4"})
65
+ Debug("TEST TOKEN", token, Constant.TINA4_LOG_DEBUG)
66
+ Debug("VALID TOKEN", tina4_auth.valid(token + "a"), Constant.TINA4_LOG_DEBUG)
67
+ Debug("VALID TOKEN", tina4_auth.valid(token), Constant.TINA4_LOG_DEBUG)
68
+ Debug("PAYLOAD", tina4_auth.get_payload(token), Constant.TINA4_LOG_DEBUG)
69
+
70
+ if "TINA4_SECRET" in os.environ:
71
+ tina4_secret = os.environ["TINA4_SECRET"]
72
+
73
+ # Hack for local development
74
+ if root_path.count("tina4_python") > 0:
75
+ root_path = root_path.split("tina4_python")[0][:-1]
76
+
77
+ # Make the beginning files for the tina4stack
78
+ if not os.path.exists(root_path + os.sep + "src"):
79
+ os.makedirs(root_path + os.sep + "src" + os.sep + "routes")
80
+ os.makedirs(root_path + os.sep + "src" + os.sep + "scss")
81
+ os.makedirs(root_path + os.sep + "src" + os.sep + "orm")
82
+ os.makedirs(root_path + os.sep + "src" + os.sep + "app")
83
+ with open(root_path + os.sep + "src" + os.sep + "__init__.py", 'w') as init_file:
84
+ init_file.write('# Start your project here')
85
+ init_file.write('\n')
86
+ if not os.path.isfile(root_path + os.sep + "app.py") and not os.path.isdir(root_path + os.sep + "tina4_python"):
87
+ with open(root_path + os.sep + "app.py", 'w') as app_file:
88
+ app_file.write('# Starting point for tina4_python, you shouldn''t need to change anything here')
89
+ app_file.write('\n')
90
+ app_file.write('from tina4_python import *')
91
+ app_file.write('\n')
92
+
93
+ if not os.path.exists(root_path + os.sep + "src" + os.sep + "app"):
94
+ os.makedirs(root_path + os.sep + "src" + os.sep + "app")
95
+
96
+ # copy over templates if needed - required for errors
97
+ if not os.path.exists(root_path + os.sep + "src" + os.sep + "templates"):
98
+ source_dir = library_path + os.sep + "templates"
99
+ destination_dir = root_path + os.sep + "src" + os.sep + "templates"
100
+ shutil.copytree(source_dir, destination_dir)
101
+
102
+ # copy over public if needed - required for static files like images and logos
103
+ if not os.path.exists(root_path + os.sep + "src" + os.sep + "public"):
104
+ source_dir = library_path + os.sep + "public"
105
+ destination_dir = root_path + os.sep + "src" + os.sep + "public"
106
+ shutil.copytree(source_dir, destination_dir)
107
+
108
+ # please keep in place otherwise autoloading of files does not work nicely, if you want this to work
109
+ # add __init__.py files in your folders
110
+ # ignore F403
111
+ if os.path.exists(root_path + os.sep + "src"):
112
+ try:
113
+ from src import *
114
+ except ImportError:
115
+ Debug("Cannot import src folder", Constant.TINA4_LOG_ERROR)
116
+ else:
117
+ Debug("Missing src folder", Constant.TINA4_LOG_WARNING)
118
+
119
+ if os.path.exists(root_path + os.sep + "src" + os.sep + "routes"):
120
+ try:
121
+ from src.routes import *
122
+ except ImportError:
123
+ Debug("Cannot import src.routes folder", Constant.TINA4_LOG_ERROR)
124
+ else:
125
+ Debug("Missing src/routes folder", Constant.TINA4_LOG_WARNING)
126
+
127
+ if os.path.exists(root_path + os.sep + "src" + os.sep + "app"):
128
+ try:
129
+ from src.app import *
130
+ except ImportError:
131
+ Debug("Cannot import src.app folder", Constant.TINA4_LOG_ERROR)
132
+ else:
133
+ Debug("Missing src/app folder", Constant.TINA4_LOG_WARNING)
134
+
135
+ # compile sass
136
+ def compile_scss():
137
+ try:
138
+ if os.path.exists(root_path + os.sep + "src" + os.sep + "scss"):
139
+ Debug("Compiling scss", Constant.TINA4_LOG_DEBUG)
140
+ sass.compile(dirname=(root_path + os.sep + 'src' + os.sep + 'scss',
141
+ root_path + os.sep + 'src' + os.sep + 'public' + os.sep + 'css'),
142
+ output_style='compressed')
143
+ except sass.CompileError as E:
144
+ Debug('Error compiling SASS ', E, Constant.TINA4_LOG_ERROR)
145
+
146
+
147
+ compile_scss()
148
+
149
+
150
+ class SassCompiler(FileSystemEventHandler):
151
+ def on_modified(self, event: FileSystemEvent) -> None:
152
+ if not event.is_directory:
153
+ compile_scss()
154
+
155
+
156
+ if os.path.exists(root_path + os.sep + "src" + os.sep + "scss"):
157
+ observer = Observer()
158
+ event_handler = SassCompiler()
159
+ observer.schedule(event_handler, path=root_path + os.sep + "src" + os.sep + "scss", recursive=True)
160
+ observer.start()
161
+ else:
162
+ Debug("Missing scss folder", Constant.TINA4_LOG_WARNING)
163
+
164
+ # end compile sass
165
+
166
+
167
+ def file_get_contents(file_path):
168
+ return Path(file_path).read_text()
169
+
170
+ # Add swagger routes
171
+ @get("/swagger/swagger.json")
172
+ async def get_swagger_json(request, response):
173
+ json = Swagger.get_json(request)
174
+ return response(json)
175
+
176
+ @get("/swagger")
177
+ async def get_swagger(request, response):
178
+ html = file_get_contents(root_path + os.sep +"src"+os.sep+"public"+ os.sep+"swagger"+os.sep+"index.html")
179
+ return response(html)
180
+
181
+ def webserver(host_name, port):
182
+ web_server = Webserver(host_name, int(port)) # HTTPServer((host_name, int(port)), Webserver)
183
+ web_server.router_handler = Router()
184
+ # Fix the display to make it clickable
185
+ if host_name == "0.0.0.0":
186
+ host_name = "localhost"
187
+ Debug(Messages.MSG_SERVER_STARTED.format(host_name=host_name, port=port), Constant.TINA4_LOG_INFO)
188
+ try:
189
+ asyncio.run(web_server.serve_forever())
190
+ except KeyboardInterrupt:
191
+ pass
192
+ web_server.server_close()
193
+ Debug(Messages.MSG_SERVER_STOPPED, Constant.TINA4_LOG_INFO)
194
+
195
+
196
+ def run_web_server(in_hostname="localhost", in_port=7145):
197
+ Debug(Messages.MSG_STARTING_WEBSERVER.format(port=in_port), Constant.TINA4_LOG_INFO)
198
+ webserver(in_hostname, in_port)
199
+
200
+ if os.getenv('TINA4_DEFAULT_WEBSERVER', 'True') == 'True' :
201
+ if importlib.util.find_spec("jurigged"):
202
+ Debug("Jurigged enabled", Constant.TINA4_LOG_INFO)
203
+ jurigged.watch("./")
204
+
205
+ # Start up a webserver based on params passed on the command line
206
+ HOSTNAME = "localhost"
207
+ PORT = 7145
208
+ if len(sys.argv) > 1:
209
+ PORT = sys.argv[1]
210
+ if ":" in PORT:
211
+ SERVER_CONFIG = PORT.split(":")
212
+ HOSTNAME = SERVER_CONFIG[0]
213
+ PORT = SERVER_CONFIG[1]
214
+
215
+ if PORT != "stop" and PORT != "manual":
216
+ try:
217
+ PORT = int(PORT)
218
+ run_web_server(HOSTNAME, PORT)
219
+ except Exception:
220
+ Debug("Not running webserver", Constant.TINA4_LOG_WARNING)
221
+ else:
222
+ Debug("Webserver is set to manual start, please call " + ShellColors.bright_red +
223
+ "run_web_server(<HOSTNAME>, <PORT>)" + ShellColors.end + " in your code",
224
+ Constant.TINA4_LOG_WARNING)
@@ -1,223 +0,0 @@
1
- #
2
- # Tina4 - This is not a 4ramework.
3
- # Copy-right 2007 - current Tina4
4
- # License: MIT https://opensource.org/licenses/MIT
5
- #
6
- # flake8: noqa: E403,F401,E402
7
- import asyncio
8
- import gettext
9
- import os
10
- import shutil
11
- import importlib
12
- import sys
13
- import sass
14
- from pathlib import Path
15
- from watchdog.observers import Observer
16
- from watchdog.events import FileSystemEventHandler, FileSystemEvent
17
-
18
- from tina4_python.Router import get
19
- from tina4_python import Messages, Constant
20
- from tina4_python.Swagger import Swagger
21
- from tina4_python.Env import load_env
22
- from tina4_python.Webserver import Webserver
23
- from tina4_python.Router import Router, get
24
- from tina4_python.Localization import localize
25
- from tina4_python.Auth import Auth
26
- from tina4_python.Debug import Debug
27
- from tina4_python.ShellColors import ShellColors
28
-
29
- _ = gettext.gettext
30
-
31
- # Server startup messages
32
- MSG_ASSUMING_ROOT_PATH = _('Assuming root path: {root_path}, library path: {library_path}')
33
- MSG_LOAD_ALL_THINGS = _('Load all things')
34
- MSG_SERVER_STARTED = _('Server started http://{host_name}:{port}')
35
- MSG_SERVER_STOPPED = _('Server stopped.')
36
- MSG_STARTING_WEBSERVER = _('Starting webserver on {port}')
37
- MSG_ENTRY_POINT_NAME = _('Entry point name ... {name}')
38
-
39
- if os.getenv('environment') is not None:
40
- environment = ".env." + os.getenv('environment')
41
- else:
42
- environment = ".env"
43
-
44
- load_env(environment)
45
- if os.getenv('TINA4_DEFAULT_WEBSERVER', 'True') == 'True' :
46
- print(ShellColors.bright_yellow + "Setting debug mode", os.getenv("TINA4_DEBUG_LEVEL"), ShellColors.end)
47
- localize()
48
-
49
- if importlib.util.find_spec("jurigged"):
50
- import jurigged
51
-
52
- # Define the variable to be used for global routes
53
- library_path = os.path.dirname(os.path.realpath(__file__))
54
- root_path = os.path.realpath(os.getcwd())
55
- Debug(Messages.MSG_ASSUMING_ROOT_PATH.format(root_path=root_path, library_path=library_path),
56
- Constant.TINA4_LOG_INFO)
57
-
58
-
59
- tina4_routes = {}
60
- tina4_current_request = {}
61
- tina4_secret = None
62
- tina4_auth = Auth(root_path)
63
-
64
- token = tina4_auth.get_token({"name": "Tina4"})
65
- Debug("TEST TOKEN", token, Constant.TINA4_LOG_DEBUG)
66
- Debug("VALID TOKEN", tina4_auth.valid(token + "a"), Constant.TINA4_LOG_DEBUG)
67
- Debug("VALID TOKEN", tina4_auth.valid(token), Constant.TINA4_LOG_DEBUG)
68
- Debug("PAYLOAD", tina4_auth.get_payload(token), Constant.TINA4_LOG_DEBUG)
69
-
70
- if "TINA4_SECRET" in os.environ:
71
- tina4_secret = os.environ["TINA4_SECRET"]
72
-
73
- # Hack for local development
74
- if root_path.count("tina4_python") > 0:
75
- root_path = root_path.split("tina4_python")[0][:-1]
76
-
77
- # Make the beginning files for the tina4stack
78
- if not os.path.exists(root_path + os.sep + "src"):
79
- os.makedirs(root_path + os.sep + "src" + os.sep + "routes")
80
- os.makedirs(root_path + os.sep + "src" + os.sep + "scss")
81
- os.makedirs(root_path + os.sep + "src" + os.sep + "orm")
82
- os.makedirs(root_path + os.sep + "src" + os.sep + "app")
83
- with open(root_path + os.sep + "src" + os.sep + "__init__.py", 'w') as init_file:
84
- init_file.write('# Start your project here')
85
- init_file.write('\n')
86
- if not os.path.isfile(root_path + os.sep + "app.py") and not os.path.isdir(root_path + os.sep + "tina4_python"):
87
- with open(root_path + os.sep + "app.py", 'w') as app_file:
88
- app_file.write('# Starting point for tina4_python, you shouldn''t need to change anything here')
89
- app_file.write('\n')
90
- app_file.write('from tina4_python import *')
91
- app_file.write('\n')
92
-
93
- if not os.path.exists(root_path + os.sep + "src" + os.sep + "app"):
94
- os.makedirs(root_path + os.sep + "src" + os.sep + "app")
95
-
96
- # copy over templates if needed - required for errors
97
- if not os.path.exists(root_path + os.sep + "src" + os.sep + "templates"):
98
- source_dir = library_path + os.sep + "templates"
99
- destination_dir = root_path + os.sep + "src" + os.sep + "templates"
100
- shutil.copytree(source_dir, destination_dir)
101
-
102
- # copy over public if needed - required for static files like images and logos
103
- if not os.path.exists(root_path + os.sep + "src" + os.sep + "public"):
104
- source_dir = library_path + os.sep + "public"
105
- destination_dir = root_path + os.sep + "src" + os.sep + "public"
106
- shutil.copytree(source_dir, destination_dir)
107
-
108
- # please keep in place otherwise autoloading of files does not work nicely, if you want this to work
109
- # add __init__.py files in your folders
110
- # ignore F403
111
- if os.path.exists(root_path + os.sep + "src"):
112
- try:
113
- from src import *
114
- except ImportError:
115
- Debug("Cannot import src folder", Constant.TINA4_LOG_ERROR)
116
- else:
117
- Debug("Missing src folder", Constant.TINA4_LOG_WARNING)
118
-
119
- if os.path.exists(root_path + os.sep + "src" + os.sep + "routes"):
120
- try:
121
- from src.routes import *
122
- except ImportError:
123
- Debug("Cannot import src.routes folder", Constant.TINA4_LOG_ERROR)
124
- else:
125
- Debug("Missing src/routes folder", Constant.TINA4_LOG_WARNING)
126
-
127
- if os.path.exists(root_path + os.sep + "src" + os.sep + "app"):
128
- try:
129
- from src.app import *
130
- except ImportError:
131
- Debug("Cannot import src.app folder", Constant.TINA4_LOG_ERROR)
132
- else:
133
- Debug("Missing src/app folder", Constant.TINA4_LOG_WARNING)
134
-
135
- # compile sass
136
- def compile_scss():
137
- try:
138
- if os.path.exists(root_path + os.sep + "src" + os.sep + "scss"):
139
- Debug("Compiling scss", Constant.TINA4_LOG_DEBUG)
140
- sass.compile(dirname=(root_path + os.sep + 'src' + os.sep + 'scss',
141
- root_path + os.sep + 'src' + os.sep + 'public' + os.sep + 'css'),
142
- output_style='compressed')
143
- except sass.CompileError as E:
144
- Debug('Error compiling SASS ', E, Constant.TINA4_LOG_ERROR)
145
-
146
-
147
- compile_scss()
148
-
149
-
150
- class SassCompiler(FileSystemEventHandler):
151
- def on_modified(self, event: FileSystemEvent) -> None:
152
- if not event.is_directory:
153
- compile_scss()
154
-
155
-
156
- if os.path.exists(root_path + os.sep + "src" + os.sep + "scss"):
157
- observer = Observer()
158
- event_handler = SassCompiler()
159
- observer.schedule(event_handler, path=root_path + os.sep + "src" + os.sep + "scss", recursive=True)
160
- observer.start()
161
- else:
162
- Debug("Missing scss folder", Constant.TINA4_LOG_WARNING)
163
-
164
- # end compile sass
165
-
166
-
167
- def file_get_contents(file_path):
168
- return Path(file_path).read_text()
169
-
170
- # Add swagger routes
171
- @get("/swagger/swagger.json")
172
- async def get_swagger_json(request, response):
173
- json = Swagger.get_json(request)
174
- return response(json)
175
-
176
- @get("/swagger")
177
- async def get_swagger(request, response):
178
- html = file_get_contents(root_path + os.sep +"src"+os.sep+"public"+ os.sep+"swagger"+os.sep+"index.html")
179
- return response(html)
180
-
181
- def webserver(host_name, port):
182
- web_server = Webserver(host_name, int(port)) # HTTPServer((host_name, int(port)), Webserver)
183
- web_server.router_handler = Router()
184
- # Fix the display to make it clickable
185
- if host_name == "0.0.0.0":
186
- host_name = "localhost"
187
- Debug(Messages.MSG_SERVER_STARTED.format(host_name=host_name, port=port), Constant.TINA4_LOG_INFO)
188
- try:
189
- asyncio.run(web_server.serve_forever())
190
- except KeyboardInterrupt:
191
- pass
192
- web_server.server_close()
193
- Debug(Messages.MSG_SERVER_STOPPED, Constant.TINA4_LOG_INFO)
194
-
195
-
196
- def run_web_server(in_hostname="localhost", in_port=7145):
197
- Debug(Messages.MSG_STARTING_WEBSERVER.format(port=in_port), Constant.TINA4_LOG_INFO)
198
- webserver(in_hostname, in_port)
199
-
200
- if importlib.util.find_spec("jurigged"):
201
- Debug("Jurigged enabled", Constant.TINA4_LOG_INFO)
202
- jurigged.watch("./")
203
-
204
- # Start up a webserver based on params passed on the command line
205
- HOSTNAME = "localhost"
206
- PORT = 7145
207
- if len(sys.argv) > 1:
208
- PORT = sys.argv[1]
209
- if ":" in PORT:
210
- SERVER_CONFIG = PORT.split(":")
211
- HOSTNAME = SERVER_CONFIG[0]
212
- PORT = SERVER_CONFIG[1]
213
-
214
- if PORT != "stop" and PORT != "manual":
215
- try:
216
- PORT = int(PORT)
217
- run_web_server(HOSTNAME, PORT)
218
- except Exception:
219
- Debug("Not running webserver", Constant.TINA4_LOG_WARNING)
220
- else:
221
- Debug("Webserver is set to manual start, please call " + ShellColors.bright_red +
222
- "run_web_server(<HOSTNAME>, <PORT>)" + ShellColors.end + " in your code",
223
- Constant.TINA4_LOG_WARNING)
File without changes