diff --git a/.gitmodules b/.gitmodules index 3988a16..aed31fc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "app/static/javascripts/term.js"] - path = app/static/javascripts/term.js +[submodule "butterfly/static/javascripts/term.js"] + path = butterfly/static/javascripts/term.js url = git@github.com:paradoxxxzero/term.js.git diff --git a/butterfly.py b/butterfly.server.py similarity index 92% rename from butterfly.py rename to butterfly.server.py index 53bf0c3..d9eb73e 100644 --- a/butterfly.py +++ b/butterfly.server.py @@ -39,7 +39,7 @@ log.debug('Starting server') ioloop = tornado.ioloop.IOLoop.instance() -from app import application +from butterfly import application application.listen(tornado.options.options.port) @@ -54,9 +54,9 @@ except ImportError: else: sporadic_reload({'url': url}) - files = ['app/static/javascripts/', - 'app/static/stylesheets/', - 'app/templates/'] + files = ['butterfly/static/javascripts/', + 'butterfly/static/stylesheets/', + 'butterfly/templates/'] watch({'url': url}, files, unwatch_at_exit=True) log.debug('Starting loop') diff --git a/butterfly.service b/butterfly.service index 5403a7b..6ae2396 100644 --- a/butterfly.service +++ b/butterfly.service @@ -3,7 +3,7 @@ Description=Butterfly Terminal Server After=syslog.target [Service] -ExecStart=/usr/bin/butterfly.py +ExecStart=/usr/bin/butterfly.server.py Restart=on-abort [Install] diff --git a/app/__init__.py b/butterfly/__init__.py similarity index 97% rename from app/__init__.py rename to butterfly/__init__.py index bfd7391..3271d9e 100644 --- a/app/__init__.py +++ b/butterfly/__init__.py @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -__version__ = '1.0' +__version__ = '1.0.1' import os @@ -51,4 +51,4 @@ class Route(tornado.web.RequestHandler): return log -import app.routes +import butterfly.routes diff --git a/app/routes.py b/butterfly/routes.py similarity index 86% rename from app/routes.py rename to butterfly/routes.py index 753bf1c..cc181aa 100644 --- a/app/routes.py +++ b/butterfly/routes.py @@ -26,7 +26,7 @@ import tornado.websocket import tornado.process import tornado.ioloop import tornado.options -from app import url, Route +from butterfly import url, Route ioloop = tornado.ioloop.IOLoop.instance() @@ -122,16 +122,31 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler): @property def uid(self): - with open('/proc/net/tcp') as k: - lines = k.readlines() - for line in lines: - # Look for local address with peer port - if line.split()[1] == '0100007F:%X' % self.port: - # We got the user - return int(line.split()[7]) + try: + with open('/proc/net/tcp') as k: + lines = k.readlines() + for line in lines: + # Look for local address with peer port + if line.split()[1] == '0100007F:%X' % self.port: + # We got the user + return int(line.split()[7]) + except: + pass + try: + with open('/proc/net/tcp6') as k: + lines = k.readlines() + for line in lines: + # Look for local address with peer port + if line.split()[1] == ( + '00000000000000000000000001000000:%X' % self.port): + # We got the user + return int(line.split()[7]) + except: + pass def open(self, user, path): - self.bind, self.port = self.ws_connection.stream.socket.getpeername() + self.bind, self.port = ( + self.ws_connection.stream.socket.getpeername()[:2]) self.log.info('Websocket opened for %s:%d' % (self.bind, self.port)) self.set_nodelay(True) self.user = user.decode('utf-8') if user else None diff --git a/app/static/coffees/main.coffee b/butterfly/static/coffees/main.coffee similarity index 100% rename from app/static/coffees/main.coffee rename to butterfly/static/coffees/main.coffee diff --git a/app/static/config.rb b/butterfly/static/config.rb similarity index 100% rename from app/static/config.rb rename to butterfly/static/config.rb diff --git a/app/static/fonts/SIL Open Font License.txt b/butterfly/static/fonts/SIL Open Font License.txt similarity index 100% rename from app/static/fonts/SIL Open Font License.txt rename to butterfly/static/fonts/SIL Open Font License.txt diff --git a/app/static/fonts/SourceCodePro-Black.otf b/butterfly/static/fonts/SourceCodePro-Black.otf similarity index 100% rename from app/static/fonts/SourceCodePro-Black.otf rename to butterfly/static/fonts/SourceCodePro-Black.otf diff --git a/app/static/fonts/SourceCodePro-Bold.otf b/butterfly/static/fonts/SourceCodePro-Bold.otf similarity index 100% rename from app/static/fonts/SourceCodePro-Bold.otf rename to butterfly/static/fonts/SourceCodePro-Bold.otf diff --git a/app/static/fonts/SourceCodePro-ExtraLight.otf b/butterfly/static/fonts/SourceCodePro-ExtraLight.otf similarity index 100% rename from app/static/fonts/SourceCodePro-ExtraLight.otf rename to butterfly/static/fonts/SourceCodePro-ExtraLight.otf diff --git a/app/static/fonts/SourceCodePro-Light.otf b/butterfly/static/fonts/SourceCodePro-Light.otf similarity index 100% rename from app/static/fonts/SourceCodePro-Light.otf rename to butterfly/static/fonts/SourceCodePro-Light.otf diff --git a/app/static/fonts/SourceCodePro-Medium.otf b/butterfly/static/fonts/SourceCodePro-Medium.otf similarity index 100% rename from app/static/fonts/SourceCodePro-Medium.otf rename to butterfly/static/fonts/SourceCodePro-Medium.otf diff --git a/app/static/fonts/SourceCodePro-Regular.otf b/butterfly/static/fonts/SourceCodePro-Regular.otf similarity index 100% rename from app/static/fonts/SourceCodePro-Regular.otf rename to butterfly/static/fonts/SourceCodePro-Regular.otf diff --git a/app/static/fonts/SourceCodePro-Semibold.otf b/butterfly/static/fonts/SourceCodePro-Semibold.otf similarity index 100% rename from app/static/fonts/SourceCodePro-Semibold.otf rename to butterfly/static/fonts/SourceCodePro-Semibold.otf diff --git a/app/static/images/favicon.png b/butterfly/static/images/favicon.png similarity index 100% rename from app/static/images/favicon.png rename to butterfly/static/images/favicon.png diff --git a/app/static/javascripts/main.js b/butterfly/static/javascripts/main.js similarity index 100% rename from app/static/javascripts/main.js rename to butterfly/static/javascripts/main.js diff --git a/app/static/javascripts/term.js b/butterfly/static/javascripts/term.js similarity index 100% rename from app/static/javascripts/term.js rename to butterfly/static/javascripts/term.js diff --git a/app/static/sass/main.sass b/butterfly/static/sass/main.sass similarity index 100% rename from app/static/sass/main.sass rename to butterfly/static/sass/main.sass diff --git a/app/static/stylesheets/fonts/glyphicons-halflings-regular.eot b/butterfly/static/stylesheets/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from app/static/stylesheets/fonts/glyphicons-halflings-regular.eot rename to butterfly/static/stylesheets/fonts/glyphicons-halflings-regular.eot diff --git a/app/static/stylesheets/fonts/glyphicons-halflings-regular.svg b/butterfly/static/stylesheets/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from app/static/stylesheets/fonts/glyphicons-halflings-regular.svg rename to butterfly/static/stylesheets/fonts/glyphicons-halflings-regular.svg diff --git a/app/static/stylesheets/fonts/glyphicons-halflings-regular.ttf b/butterfly/static/stylesheets/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from app/static/stylesheets/fonts/glyphicons-halflings-regular.ttf rename to butterfly/static/stylesheets/fonts/glyphicons-halflings-regular.ttf diff --git a/app/static/stylesheets/fonts/glyphicons-halflings-regular.woff b/butterfly/static/stylesheets/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from app/static/stylesheets/fonts/glyphicons-halflings-regular.woff rename to butterfly/static/stylesheets/fonts/glyphicons-halflings-regular.woff diff --git a/app/static/stylesheets/main.css b/butterfly/static/stylesheets/main.css similarity index 100% rename from app/static/stylesheets/main.css rename to butterfly/static/stylesheets/main.css diff --git a/app/templates/index.html b/butterfly/templates/index.html similarity index 100% rename from app/templates/index.html rename to butterfly/templates/index.html diff --git a/dev.py b/dev.py index 305feea..a926e38 100755 --- a/dev.py +++ b/dev.py @@ -7,9 +7,9 @@ import sys import shlex commands = [ - 'coffee -wcb -j app/static/javascripts/main.js ' + - ' '.join(glob('app/static/coffees/*.coffee')), - 'compass watch app/static', + 'coffee -wcb -j butterfly/static/javascripts/main.js ' + + ' '.join(glob('butterfly/static/coffees/*.coffee')), + 'compass watch butterfly/static', 'python butterfly.py ' + ' '.join(sys.argv[1:]) ] diff --git a/setup.py b/setup.py index 9db3e0d..1c932b2 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ import re from setuptools import setup ROOT = os.path.dirname(__file__) -with open(os.path.join(ROOT, 'app', '__init__.py')) as fd: +with open(os.path.join(ROOT, 'butterfly', '__init__.py')) as fd: __version__ = re.search("__version__ = '([^']+)'", fd.read()).group(1) options = dict( @@ -22,12 +22,11 @@ options = dict( url="http://github.com/paradoxxxzero/butterfly", license="GPLv3", platforms="Any", - scripts=['butterfly.py'], - packages=['app'], + scripts=['butterfly.server.py'], + packages=['butterfly'], install_requires=["tornado"], - package_dir={'butterfly': 'app'}, package_data={ - 'app': [ + 'butterfly': [ 'static/fonts/*', 'static/stylesheets/main.css', 'static/javascripts/term.js/src/term.js', @@ -39,7 +38,7 @@ options = dict( "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Operating System :: Linux", + "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Terminals"])