|
- #!C:\Green_GoodERP18_FSJ\python\python.exe
- def Is_child_processing():
- from multiprocessing.connection import Listener
- from queue import Queue
- from threading import Thread
- q = Queue()
-
- def lock_system_port(_port):
- nonlocal q
- try:
- listener = Listener(("", _port))
- q.put(False)
- except Exception:
- q.put(True)
- return
-
- while True:
- serv = listener.accept()
-
- t = Thread(target=lock_system_port, args=(62771,))
- t.setDaemon(True)
- t.start();
- del t;
- return q.get()
-
- def enable_browser_with_delay(argv, _t=None):
- try:
- subcommand = argv[1]
- except IndexError:
- pass
-
- if subcommand == 'runserver' and '--noreload' not in argv:
- try:
- parser_port = argv[2]
- port_with_colon = parser_port[parser_port.index(":"):]
- except (IndexError, ValueError):
- port_with_colon = ":8000"
- finally:
- import webbrowser
- import time
- if not _t: _t = 0.5
- time.sleep(_t)
- webbrowser.open_new("http://localhost" + port_with_colon)
-
- import os
- import sys
-
-
- def main():
- """Run administrative tasks."""
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smart_chart.smartchart.settings')
- try:
- from django.core.management import execute_from_command_line
- except ImportError as exc:
- raise ImportError(
- "Couldn't import Django. Are you sure it's installed and "
- "available on your PYTHONPATH environment variable? Did you "
- "forget to activate a virtual environment?"
- ) from exc
- if len(sys.argv) == 1:
- sys.argv.extend(['runserver', '--insecure'])
- try:
- if Is_child_processing():
- import threading
- t = threading.Thread(target=enable_browser_with_delay, args=(sys.argv, 1))
- t.start(); del t;
- except Exception as e:
- print(str(e.args))
- execute_from_command_line(sys.argv)
-
-
- if __name__ == '__main__':
- main()
|