MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / main

Function main

zeronet.py:6–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6def main():
7 if sys.version_info.major < 3:
8 print("Error: Python 3.x is required")
9 sys.exit(0)
10
11 if "--silent" not in sys.argv:
12 print("- Starting ZeroNet...")
13
14 main = None
15 try:
16 import main
17 main.start()
18 except Exception as err: # Prevent closing
19 import traceback
20 try:
21 import logging
22 logging.exception("Unhandled exception: %s" % err)
23 except Exception as log_err:
24 print("Failed to log error:", log_err)
25 traceback.print_exc()
26 from Config import config
27 error_log_path = config.log_dir + "/error.log"
28 traceback.print_exc(file=open(error_log_path, "w"))
29 print("---")
30 print("Please report it: https://github.com/HelloZeroNet/ZeroNet/issues/new?assignees=&labels=&template=bug-report.md")
31 if sys.platform.startswith("win"):
32 displayErrorMessage(err, error_log_path)
33
34 if main and (main.update_after_shutdown or main.restart_after_shutdown): # Updater
35 if main.update_after_shutdown:
36 print("Shutting down...")
37 prepareShutdown()
38 import update
39 print("Updating...")
40 update.update()
41 print("Restarting...")
42 restart()
43 else:
44 print("Shutting down...")
45 prepareShutdown()
46 print("Restarting...")
47 restart()
48
49
50def displayErrorMessage(err, error_log_path):

Callers 1

startFunction · 0.70

Calls 5

displayErrorMessageFunction · 0.85
prepareShutdownFunction · 0.85
restartFunction · 0.85
startMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected