~romaimperator/keryx/devel

« back to all changes in this revision

Viewing changes to keryx.py

  • Committer: Chris Oliver
  • Date: 2009-09-13 02:41:43 UTC
  • Revision ID: excid3@gmail.com-20090913024143-27uo2tfmw68xp341
Restructured database into classes with proper sqlalchemy usage

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
__author__    = 'Buran Ayuthia'
9
9
 
10
10
import logging
 
11
import os
11
12
from sys import argv, exit
12
13
from optparse import OptionParser, OptionGroup
13
14
import libkeryx
44
45
 
45
46
FORMAT = '%(asctime)s %(levelname)-8s %(message)s'
46
47
DATE = '%a, %d %b %Y %H:%M:%S'
47
 
 
 
48
db_filename = os.path.join(os.path.dirname(__file__), 'keryx.db')
48
49
 
49
50
class Keryx:
50
51
    def __init__(self):
59
60
        command_list = ['create', 'update', 'download', 'remove', \
60
61
                        'clean', 'showpkg', 'dump', 'unmet', 'search', \
61
62
                        'show', 'depends', 'pkgnames']
62
 
        usage = 'usage: %prog project command [options]\n\n' + \
63
 
                'Actions (if none is specified, Keryx will enter ' + \
 
63
        usage = 'usage: %prog project command [options]\n\n' \
 
64
                'Actions (if none is specified, Keryx will enter ' \
64
65
                'GUI mode):'
65
66
        version = __version__
66
 
        description = 'create   - Create a new project      ' + \
67
 
                      '                                     ' + \
68
 
                      'update   - Get updated package list from the ' + \
69
 
                      'Internet                                     ' + \
70
 
                      'download - Download selected packages for ' + \
71
 
                      'the project                               ' + \
72
 
                      'remove   - Removes a package from the download ' + \
73
 
                      'list                                           ' + \
74
 
                      'clean    - Removes all the packages from the ' + \
75
 
                      'download list                                ' + \
76
 
                      'showpkg  - Display general information for a ' + \
77
 
                      'package                                      ' + \
78
 
                      'search   - Display packages that match the ' + \
79
 
                      'search string                              ' + \
80
 
                      'show     - Display information about a ' + \
81
 
                      'particular package                     ' + \
82
 
                      'depends  - Display the dependencies for a ' + \
83
 
                      'particular package                        ' + \
 
67
        description = 'create   - Create a new project      ' \
 
68
                      '                                     ' \
 
69
                      'update   - Get updated package list from the ' \
 
70
                      'Internet                                     ' \
 
71
                      'download - Download selected packages for ' \
 
72
                      'the project                               ' \
 
73
                      'remove   - Removes a package from the download ' \
 
74
                      'list                                           ' \
 
75
                      'clean    - Removes all the packages from the ' \
 
76
                      'download list                                ' \
 
77
                      'showpkg  - Display general information for a ' \
 
78
                      'package                                      ' \
 
79
                      'search   - Display packages that match the ' \
 
80
                      'search string                              ' \
 
81
                      'show     - Display information about a ' \
 
82
                      'particular package                     ' \
 
83
                      'depends  - Display the dependencies for a ' \
 
84
                      'particular package                        ' \
84
85
                      'pkgnames - List the names of all the packages'
85
86
        parser = OptionParser(usage, description=description, version=version)
86
87
 
103
104
#            dest='force', \
104
105
#            help='Attempt to continue if the integrity check fails')
105
106
 
106
 
        parser.add_option('-v', '--verbose', action='store_const', 
107
 
                            const=logging.INFO, dest='verbose',
108
 
                            default=logging.INFO, 
109
 
                            help='display more information')
110
 
        parser.add_option('-d', '--debug', action='store_const', 
111
 
                            const=logging.DEBUG, dest='verbose',
112
 
                            help='display debugging information')
 
107
 
113
108
 
114
109
        (options, arguments) = parser.parse_args(args)
115
 
 
 
110
        options.verbose = logging.DEBUG
116
111
        # Configure verbosity
117
112
        #TODO: Fix it so basicConfig works
118
 
        #logging.basicConfig(level=options.verbose, format=FORMAT, datefmt=DATE)
119
 
        logging.root.level = options.verbose
 
113
        logging.basicConfig(level=options.verbose, format=FORMAT, datefmt=DATE)
120
114
 
121
115
        if len(arguments) == 1:
122
116
            self.wx_gui = True
142
136
            print 'call GUI version'
143
137
        else:
144
138
            if self.command == 'create':
145
 
                definition = libkeryx.get_definition(self.project)
 
139
                definition = libkeryx.get_definition(self.project, db_filename)
146
140
                definition.create()
147
141
            if self.command == 'update':
148
 
                definition = libkeryx.get_definition(self.project)
 
142
                definition = libkeryx.get_definition(self.project, db_filename)
149
143
                definition.UpdateInternet()
150
144
 
151
145
# keryx <project-name> <command(s)> <option(s)>