ignore hidden files, ignore data dir, dont close on startup error, create necessary files and dirs on first start, start function to main.py, bad file solved log to info
This commit is contained in:
parent
e141a771ee
commit
effa267b73
6 changed files with 30 additions and 11 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -4,3 +4,11 @@ __pycache__/
|
|||
|
||||
# Log files
|
||||
*.log
|
||||
|
||||
# Hidden files
|
||||
.*
|
||||
!/.gitignore
|
||||
|
||||
|
||||
# Data dir
|
||||
data/*
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
{
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
Place for log files.
|
|
@ -297,7 +297,7 @@ class Site:
|
|||
def fileDone(self, inner_path):
|
||||
# File downloaded, remove it from bad files
|
||||
if inner_path in self.bad_files:
|
||||
self.log.debug("Bad file solved: %s" % inner_path)
|
||||
self.log.info("Bad file solved: %s" % inner_path)
|
||||
del(self.bad_files[inner_path])
|
||||
|
||||
# Update content.json last downlad time
|
||||
|
|
12
src/main.py
12
src/main.py
|
@ -1,6 +1,11 @@
|
|||
import os, sys
|
||||
sys.path.append(os.path.dirname(__file__)) # Imports relative to main.py
|
||||
|
||||
# Create necessary files and dirs
|
||||
if not os.path.isdir("log"): os.mkdir("log")
|
||||
if not os.path.isdir("data"): os.mkdir("data")
|
||||
if not os.path.isfile("data/sites.json"): open("data/sites.json", "w").write("{}")
|
||||
|
||||
# Load config
|
||||
from Config import config
|
||||
|
||||
|
@ -34,6 +39,13 @@ import time
|
|||
|
||||
logging.debug("Starting... %s" % config)
|
||||
|
||||
# Starts here when running zeronet.py
|
||||
def start():
|
||||
action_func = globals()[config.action] # Function reference
|
||||
action_kwargs = config.getActionArguments() # non-config arguments when calling zeronet.py
|
||||
|
||||
action_func(**action_kwargs)
|
||||
|
||||
|
||||
# Start serving UiServer and PeerServer
|
||||
def main():
|
||||
|
|
14
zeronet.py
14
zeronet.py
|
@ -1,7 +1,9 @@
|
|||
from src import main
|
||||
|
||||
action_func = getattr(main, main.config.action)
|
||||
action_kwargs = main.config.getActionArguments()
|
||||
|
||||
action_func(**action_kwargs)
|
||||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
from src import main
|
||||
main.start()
|
||||
except Exception, err: # Prevent closing
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
raw_input("-- Error happend, press enter to close --")
|
||||
|
|
Loading…
Reference in a new issue