From c6152c95030fc00becf5126ce4a0d573598d760e Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 8 Oct 2013 11:33:51 -0600 Subject: [PATCH] Project structure & tools (pytest, tox etc.) --- .gitignore | 1 + .travis.yml | 4 +++ LICENSE | 8 ++--- gns3-server.py | 33 +++++++++++++++++-- {gns3_server => gns3server}/__init__.py | 1 - gns3server/_compat.py | 31 +++++++++++++++++ {gns3_server => gns3server}/utils/__init__.py | 0 requirements.txt | 5 +++ setup.py | 9 +++-- tox.ini | 4 +-- 10 files changed, 82 insertions(+), 14 deletions(-) rename {gns3_server => gns3server}/__init__.py (98%) create mode 100644 gns3server/_compat.py rename {gns3_server => gns3server}/utils/__init__.py (100%) diff --git a/.gitignore b/.gitignore index d2d6f360..49bac9bd 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ nosetests.xml .mr.developer.cfg .project .pydevproject +.settings diff --git a/.travis.yml b/.travis.yml index 5f52e588..bb9aceb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,10 @@ install: script: "python setup.py test" +branches: + only: + - master + notifications: email: false irc: diff --git a/LICENSE b/LICENSE index b8deacb4..94a9ed02 100644 --- a/LICENSE +++ b/LICENSE @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Gns3-server - Copyright (C) 2013 Jeremy Grossmann + + Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Gns3-server Copyright (C) 2013 Jeremy Grossmann + Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. \ No newline at end of file +. diff --git a/gns3-server.py b/gns3-server.py index 0b43d46f..c321ee48 100644 --- a/gns3-server.py +++ b/gns3-server.py @@ -16,7 +16,36 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# Python 2.6 and 2.7 compatibility +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals -import gns3_server +import sys +import tornado.ioloop +import tornado.web +import gns3server +from datetime import date + +class MainHandler(tornado.web.RequestHandler): + def get(self): + self.write("Ready to serve") + +application = tornado.web.Application([ + (r"/", MainHandler), +]) + +if __name__ == "__main__": + + print("GNS3 server version {0}".format(gns3server.__version__)) + print("Copyright (c) 2007-{0} GNS3 Technologies Inc.".format(date.today().year)) + + if sys.version_info < (2, 6): + raise RuntimeError("Python 2.6 or higher is required") + elif sys.version_info[0] == 3 and sys.version_info < (3, 3): + raise RuntimeError("Python 3.3 or higher is required") + + application.listen(8888) + tornado.ioloop.IOLoop.instance().start() -print(gns3_server.__version__) diff --git a/gns3_server/__init__.py b/gns3server/__init__.py similarity index 98% rename from gns3_server/__init__.py rename to gns3server/__init__.py index dd249640..d98d3e92 100644 --- a/gns3_server/__init__.py +++ b/gns3server/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: UTF-8 -*- # # Copyright (C) 2013 GNS3 Technologies Inc. diff --git a/gns3server/_compat.py b/gns3server/_compat.py new file mode 100644 index 00000000..c866e3b1 --- /dev/null +++ b/gns3server/_compat.py @@ -0,0 +1,31 @@ +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2013 GNS3 Technologies Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import sys + +PY2 = sys.version_info[0] == 2 + +if not PY2: + unichr = chr + range_type = range + text_type = str + string_types = (str,) +else: + unichr = unichr + text_type = unicode + range_type = xrange + string_types = (str, unicode) diff --git a/gns3_server/utils/__init__.py b/gns3server/utils/__init__.py similarity index 100% rename from gns3_server/utils/__init__.py rename to gns3server/utils/__init__.py diff --git a/requirements.txt b/requirements.txt index e69de29b..c43f03c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1,5 @@ +Yapsy==1.10.2-pythons2n3 +astroid==1.0.0 +logilab-common==0.60.0 +networkx==1.8.1 +tornado==3.1.1 diff --git a/setup.py b/setup.py index a0426c53..cf12b787 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: UTF-8 -*- # # Copyright (C) 2013 GNS3 Technologies Inc. @@ -18,10 +17,10 @@ import sys import os -from setuptools import setup +from setuptools import setup, find_packages from setuptools.command.test import test as TestCommand -import gns3_server +import gns3server class Tox(TestCommand): def finalize_options(self): @@ -37,7 +36,7 @@ class Tox(TestCommand): setup( name = 'gns3-server', scripts = ['gns3-server.py'], - version = gns3_server.__version__, + version = gns3server.__version__, url = 'http://github.com/GNS3/gns3-server', license = 'GNU General Public License v3 (GPLv3)', tests_require = ['tox'], @@ -47,7 +46,7 @@ setup( author_email = 'package-maintainer@gns3.net', description = 'GNS3 server with HTTP REST API to manage emulators', long_description = open('README.rst', 'r').read(), - packages = ['gns3_server'], + packages = find_packages(), include_package_data = True, platforms = 'any', classifiers = [ diff --git a/tox.ini b/tox.ini index 126dc7ac..fe9bd531 100644 --- a/tox.ini +++ b/tox.ini @@ -2,5 +2,5 @@ envlist = py26, py27, pypy, py33 [testenv] -deps = nose -commands = nosetests +deps = pytest +commands = py.test