Compare commits
No commits in common. "be33608bada92485f64a239af1ddf93633ac83b8" and "57fc476500457cd916d16bb9e33f25cc6fc1b0ae" have entirely different histories.
be33608bad
...
57fc476500
26
server.py
26
server.py
|
@ -7,7 +7,6 @@ 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
|
||||||
|
@ -17,7 +16,7 @@ import tornado.gen
|
||||||
import tornado.web
|
import tornado.web
|
||||||
|
|
||||||
|
|
||||||
from camera import Camera
|
from action import Camera
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -155,8 +154,6 @@ 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'}}
|
||||||
|
@ -168,6 +165,27 @@ 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