Add a pbr compatible setup

Add a setup.cfg and setup.py and fill in those files
so that gertty can be installed easily.

Adjust gertty.py to have a main function that
can be referenced as a console entrypoint during
installation.

Also adjusted a bunch of imports that were failing after
installation occurred (but now they should not fail since they
correctly reference the gertty module namespace).

Change-Id: I532ced51583b26300ba9a2efb97f8e41bc69ec8d
This commit is contained in:
Joshua Harlow 2014-05-03 10:35:36 -07:00
parent 6505505369
commit 7a71108c60
8 changed files with 79 additions and 21 deletions

View File

@ -20,12 +20,12 @@ import threading
import urwid import urwid
import db from gertty import db
import config from gertty import config
import gitrepo from gertty import gitrepo
import mywid from gertty import mywid
import sync from gertty import sync
import view.project_list from gertty.view import project_list as view_project_list
palette=[('reversed', 'default,standout', ''), palette=[('reversed', 'default,standout', ''),
('header', 'white,bold', 'dark blue'), ('header', 'white,bold', 'dark blue'),
@ -130,7 +130,7 @@ class App(object):
self.screens = [] self.screens = []
self.status = StatusHeader(self) self.status = StatusHeader(self)
self.header = urwid.AttrMap(self.status, 'header') self.header = urwid.AttrMap(self.status, 'header')
screen = view.project_list.ProjectListView(self) screen = view_project_list.ProjectListView(self)
self.status.update(title=screen.title) self.status.update(title=screen.title)
self.loop = urwid.MainLoop(screen, palette=palette, self.loop = urwid.MainLoop(screen, palette=palette,
unhandled_input=self.unhandledInput) unhandled_input=self.unhandledInput)
@ -221,7 +221,8 @@ class App(object):
return gitrepo.Repo(self.config.url+'p/'+project_name, return gitrepo.Repo(self.config.url+'p/'+project_name,
local_path) local_path)
if __name__ == '__main__':
def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Console client for Gerrit Code Review.') description='Console client for Gerrit Code Review.')
parser.add_argument('-d', dest='debug', action='store_true', parser.add_argument('-d', dest='debug', action='store_true',
@ -233,3 +234,7 @@ if __name__ == '__main__':
args = parser.parse_args() args = parser.parse_args()
g = App(args.server, args.debug, args.no_sync) g = App(args.server, args.debug, args.no_sync)
g.run() g.run()
if __name__ == '__main__':
main()

View File

@ -16,10 +16,10 @@ import datetime
import urwid import urwid
import gitrepo from gertty import gitrepo
import mywid from gertty import mywid
import sync from gertty import sync
import view.diff from gertty.view import diff as view_diff
class ReviewDialog(urwid.WidgetWrap): class ReviewDialog(urwid.WidgetWrap):
signals = ['save', 'cancel'] signals = ['save', 'cancel']
@ -384,4 +384,4 @@ This Screen
return r return r
def diff(self, revision_key): def diff(self, revision_key):
self.app.changeScreen(view.diff.DiffView(self.app, revision_key)) self.app.changeScreen(view_diff.DiffView(self.app, revision_key))

View File

@ -14,8 +14,8 @@
import urwid import urwid
import mywid from gertty import mywid
import view.change from gertty.view import change as view_change
class ChangeRow(urwid.Button): class ChangeRow(urwid.Button):
change_focus_map = {None: 'reversed', change_focus_map = {None: 'reversed',
@ -139,4 +139,4 @@ This Screen
return super(ChangeListView, self).keypress(size, key) return super(ChangeListView, self).keypress(size, key)
def onSelect(self, button, change_key): def onSelect(self, button, change_key):
self.app.changeScreen(view.change.ChangeView(self.app, change_key)) self.app.changeScreen(view_change.ChangeView(self.app, change_key))

View File

@ -17,7 +17,7 @@ import logging
import urwid import urwid
import mywid from gertty import mywid
class LineContext(object): class LineContext(object):
def __init__(self, old_revision_key, new_revision_key, def __init__(self, old_revision_key, new_revision_key,

View File

@ -14,9 +14,9 @@
import urwid import urwid
import mywid from gertty import mywid
import sync from gertty import sync
import view.change_list from gertty.view import change_list as view_change_list
class ProjectRow(urwid.Button): class ProjectRow(urwid.Button):
project_focus_map = {None: 'reversed', project_focus_map = {None: 'reversed',
@ -113,7 +113,7 @@ This Screen
return ret return ret
def onSelect(self, button, project_key): def onSelect(self, button, project_key):
self.app.changeScreen(view.change_list.ChangeListView(self.app, project_key)) self.app.changeScreen(view_change_list.ChangeListView(self.app, project_key))
def keypress(self, size, key): def keypress(self, size, key):
if key=='l': if key=='l':

View File

@ -4,3 +4,4 @@ GitPython>=0.3.2.RC1
python-dateutil python-dateutil
requests requests
ordereddict ordereddict
pbr>=0.6,!=0.7,<1.0

32
setup.cfg Normal file
View File

@ -0,0 +1,32 @@
[metadata]
name = gertty
summary = Gertty is a console-based interface to the Gerrit Code Review system.
description-file =
README.rst
author = OpenStack
author-email = openstack-dev@lists.openstack.org
home-page = http://www.openstack.org/
classifier =
Topic :: Utilities
Intended Audience :: Developers
Intended Audience :: Information Technology
Intended Audience :: System Administrators
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 2.6
keywords = gerrit console urwid review
[global]
setup-hooks =
pbr.hooks.setup_hook
[files]
packages =
gertty
[entry_points]
console_scripts =
gertty = gertty.app:main

20
setup.py Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env python
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import setuptools
setuptools.setup(
setup_requires=['pbr'],
pbr=True)