MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / main

Function main

web/pgAdmin4.py:160–222  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

158# The entry point
159##########################################################################
160def main():
161 # Set null device file path to stdout, stdin, stderr if they are None
162 for _name in ('stdin', 'stdout', 'stderr'):
163 if getattr(sys, _name) is None:
164 setattr(sys, _name,
165 open(os.devnull, 'r' if _name == 'stdin' else 'w'))
166
167 # Output a startup message if we're not under the runtime and startup.
168 # If we're under WSGI, we don't need to worry about this
169 if not app.PGADMIN_RUNTIME:
170 print(
171 "Starting %s. Please navigate to http://%s:%d in your browser." %
172 (config.APP_NAME, config.DEFAULT_SERVER,
173 config.EFFECTIVE_SERVER_PORT)
174 )
175 sys.stdout.flush()
176 else:
177 # For unknown reason the runtime does not pass the environment
178 # variables (i.e. PYTHONHOME, and PYTHONPATH), to the Python
179 # sub-processes, leading to failures executing background processes.
180 #
181 # This has been observed only on windows. On *nix systems, it is likely
182 # picking the system python environment, which is good enough to run
183 # the process-executor.
184 #
185 # Setting PYTHONHOME launch them properly.
186 from pgadmin.utils import IS_WIN
187
188 if IS_WIN:
189 os.environ['PYTHONHOME'] = sys.prefix
190
191 # Initialize Flask service only once
192 # If `WERKZEUG_RUN_MAIN` is None, i.e: app is initializing for first time
193 # so set `use_reloader` = False, thus reload won't call.
194 # Reference:
195 # https://github.com/pallets/werkzeug/issues/220#issuecomment-11176538
196 try:
197 if config.DEBUG:
198 app.run(
199 host=config.DEFAULT_SERVER,
200 port=config.EFFECTIVE_SERVER_PORT,
201 debug=config.DEBUG,
202 use_reloader=(
203 (not app.PGADMIN_RUNTIME) and
204 os.environ.get("WERKZEUG_RUN_MAIN") is not None
205 ),
206 threaded=config.THREADED_MODE
207 )
208 else:
209 try:
210 socketio.run(
211 app,
212 debug=config.DEBUG,
213 allow_unsafe_werkzeug=True,
214 host=config.DEFAULT_SERVER,
215 port=config.EFFECTIVE_SERVER_PORT,
216 )
217 except KeyboardInterrupt:

Callers 1

pgAdmin4.pyFile · 0.70

Calls 4

flushMethod · 0.80
errorMethod · 0.80
runMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected