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:
HelloZeroNet 2015-01-12 19:11:35 +01:00
parent e141a771ee
commit effa267b73
6 changed files with 30 additions and 11 deletions

10
.gitignore vendored
View File

@ -3,4 +3,12 @@ __pycache__/
*.py[cod]
# Log files
*.log
*.log
# Hidden files
.*
!/.gitignore
# Data dir
data/*

View File

@ -1,2 +0,0 @@
{
}

View File

@ -1 +0,0 @@
Place for log files.

View File

@ -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

View File

@ -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():

View File

@ -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 --")