This repository has been archived by the owner on Mar 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
shengxiang
committed
Mar 20, 2016
1 parent
4492cea
commit 9afddaa
Showing
6 changed files
with
105 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,3 @@ | |
|
||
- bounds | ||
- region(left, right, top, bottom) | ||
2. Patten | ||
|
||
- filename | ||
- offset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<html> | ||
<h1>Hello AirtestX</h1> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# coding: utf-8 | ||
|
||
import os | ||
import logging | ||
import webbrowser | ||
import socket | ||
|
||
import tornado.ioloop | ||
import tornado.web | ||
from atx import logutils | ||
|
||
__dir__ = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
log = logutils.getLogger("webide") | ||
log.setLevel(logging.DEBUG) | ||
|
||
|
||
def get_valid_port(): | ||
for port in range(10010, 10100): | ||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
result = sock.connect_ex(('127.0.0.1', port)) | ||
if result != 0: | ||
return port | ||
|
||
raise SystemError("Can not find a unused port, amazing!") | ||
|
||
class MainHandler(tornado.web.RequestHandler): | ||
def get(self): | ||
self.render('index.html') | ||
|
||
|
||
def make_app(settings={}): | ||
application = tornado.web.Application([ | ||
(r"/", MainHandler), | ||
], **settings) | ||
return application | ||
|
||
|
||
def main(**kws): | ||
application = make_app({ | ||
'static_path': os.path.join(__dir__, 'static'), | ||
'template_path': os.path.join(__dir__, 'static'), | ||
}) | ||
port = kws.get('port', None) | ||
if not port: | ||
port = get_valid_port() | ||
|
||
open_browser = kws.get('open_browser', True) | ||
if open_browser: | ||
url = 'http://127.0.0.1:{}'.format(port) | ||
webbrowser.open(url, new=2) # 2: open new tab if possible | ||
|
||
application.listen(port) | ||
log.info("Listening port on 127.0.0.1:{}".format(port)) | ||
tornado.ioloop.IOLoop.instance().start() | ||
|
||
if __name__ == "__main__": | ||
main() |