Compare commits
No commits in common. "57fc476500457cd916d16bb9e33f25cc6fc1b0ae" and "be33608bada92485f64a239af1ddf93633ac83b8" have entirely different histories.
57fc476500
...
be33608bad
26
server.py
26
server.py
|
@ -7,6 +7,7 @@ import queue
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from tornado.httpserver import HTTPServer
|
from tornado.httpserver import HTTPServer
|
||||||
|
@ -16,7 +17,7 @@ import tornado.gen
|
||||||
import tornado.web
|
import tornado.web
|
||||||
|
|
||||||
|
|
||||||
from action import Camera
|
from camera import Camera
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -154,6 +155,8 @@ class RPCHandler(tornado.web.RequestHandler):
|
||||||
if not error:
|
if not error:
|
||||||
try:
|
try:
|
||||||
response = yield tornado.gen.Task(api_task, request)
|
response = yield tornado.gen.Task(api_task, request)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
raise
|
||||||
except:
|
except:
|
||||||
logger.error("ERROR: %s", request, exc_info=True)
|
logger.error("ERROR: %s", request, exc_info=True)
|
||||||
error = {'error': {'code': -32000, 'message': 'Server error'}}
|
error = {'error': {'code': -32000, 'message': 'Server error'}}
|
||||||
|
@ -165,27 +168,6 @@ class RPCHandler(tornado.web.RequestHandler):
|
||||||
response = json_dumps(response)
|
response = json_dumps(response)
|
||||||
self.write(response)
|
self.write(response)
|
||||||
|
|
||||||
def prepare(encoding):
|
|
||||||
if not os.path.exists(settings['prefix']):
|
|
||||||
print('please create "%s" and start again' % settings['prefix'])
|
|
||||||
sys.exit(1)
|
|
||||||
index = os.path.join(settings['prefix'], 'index.html')
|
|
||||||
if not os.path.exists(index):
|
|
||||||
try:
|
|
||||||
with open(index, 'w') as fd:
|
|
||||||
fd.write(BANNER_PUBLIC)
|
|
||||||
except:
|
|
||||||
print('can not write to "%s"' % settings['prefix'])
|
|
||||||
sys.exit(1)
|
|
||||||
load_files(encoding)
|
|
||||||
registered = False
|
|
||||||
while not registered:
|
|
||||||
try:
|
|
||||||
register_server()
|
|
||||||
except:
|
|
||||||
logging.error('failed to register')
|
|
||||||
time.sleep(10)
|
|
||||||
registered = True
|
|
||||||
|
|
||||||
class MainHandler(tornado.web.RequestHandler):
|
class MainHandler(tornado.web.RequestHandler):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user