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
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -3,4 +3,12 @@ __pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|
||||||
# Log files
|
# Log files
|
||||||
*.log
|
*.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):
|
def fileDone(self, inner_path):
|
||||||
# File downloaded, remove it from bad files
|
# File downloaded, remove it from bad files
|
||||||
if inner_path in self.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])
|
del(self.bad_files[inner_path])
|
||||||
|
|
||||||
# Update content.json last downlad time
|
# Update content.json last downlad time
|
||||||
|
|
12
src/main.py
12
src/main.py
|
@ -1,6 +1,11 @@
|
||||||
import os, sys
|
import os, sys
|
||||||
sys.path.append(os.path.dirname(__file__)) # Imports relative to main.py
|
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
|
# Load config
|
||||||
from Config import config
|
from Config import config
|
||||||
|
|
||||||
|
@ -34,6 +39,13 @@ import time
|
||||||
|
|
||||||
logging.debug("Starting... %s" % config)
|
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
|
# Start serving UiServer and PeerServer
|
||||||
def main():
|
def main():
|
||||||
|
|
14
zeronet.py
14
zeronet.py
|
@ -1,7 +1,9 @@
|
||||||
from src import main
|
#!/usr/bin/env python
|
||||||
|
|
||||||
action_func = getattr(main, main.config.action)
|
|
||||||
action_kwargs = main.config.getActionArguments()
|
|
||||||
|
|
||||||
action_func(**action_kwargs)
|
|
||||||
|
|
||||||
|
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