keryx team mailing list archive
-
keryx team
-
Mailing list archive
-
Message #00103
[Merge] lp:~mac9416/keryx/devel into lp:keryx/devel
Jayhawk has proposed merging lp:~mac9416/keryx/devel into lp:keryx/devel.
--
https://code.launchpad.net/~mac9416/keryx/devel/+merge/10078
Your team Keryx Development Team is subscribed to branch lp:keryx/devel.
=== modified file 'keryx.py'
--- keryx.py 2009-08-11 18:24:30 +0000
+++ keryx.py 2009-08-13 01:45:08 +0000
@@ -42,74 +42,74 @@
class Keryx:
def __init__(self):
- self.command = ""
- self.project = ""
+ self.command = ''
+ self.project = ''
self.wx_gui = False
def __parse_command(self, command):
pass
def parse_options(self, args):
- command_list = ["create", "update", "download", "remove", \
- "clean", "showpkg", "dump", "unmet", "search", \
- "show", "depends", "pkgnames"]
- usage = "usage: %prog project command [options]\n\n" + \
- "Actions (if none is specified, Keryx will enter " + \
- "GUI mode):"
+ command_list = ['create', 'update', 'download', 'remove', \
+ 'clean', 'showpkg', 'dump', 'unmet', 'search', \
+ 'show', 'depends', 'pkgnames']
+ usage = 'usage: %prog project command [options]\n\n' + \
+ 'Actions (if none is specified, Keryx will enter ' + \
+ 'GUI mode):'
version = __version__
- description = "create - Create a new project " + \
- " " + \
- "update - Get updated package list from the " + \
- "Internet " + \
- "download - Download selected packages for " + \
- "the project " + \
- "remove - Removes a package from the download " + \
- "list " + \
- "clean - Removes all the packages from the " + \
- "download list " + \
- "showpkg - Display general information for a " + \
- "package " + \
- "search - Display packages that match the " + \
- "search string " + \
- "show - Display information about a " + \
- "particular package " + \
- "depends - Display the dependencies for a " + \
- "particular package " + \
- "pkgnames - List the names of all the packages"
+ description = 'create - Create a new project ' + \
+ ' ' + \
+ 'update - Get updated package list from the ' + \
+ 'Internet ' + \
+ 'download - Download selected packages for ' + \
+ 'the project ' + \
+ 'remove - Removes a package from the download ' + \
+ 'list ' + \
+ 'clean - Removes all the packages from the ' + \
+ 'download list ' + \
+ 'showpkg - Display general information for a ' + \
+ 'package ' + \
+ 'search - Display packages that match the ' + \
+ 'search string ' + \
+ 'show - Display information about a ' + \
+ 'particular package ' + \
+ 'depends - Display the dependencies for a ' + \
+ 'particular package ' + \
+ 'pkgnames - List the names of all the packages'
parser = OptionParser(usage, description=description, version=version)
- download_group = OptionGroup(parser, "Download")
- download_group.add_option("-d", "--download", action="store_true", \
- dest="download", \
- help="Download only - do NOT install or unpack archives")
- download_group.add_option("-s", "--simulate", action="store_true",
- dest="simulate", help="No-act. Perform ordering simulation")
- download_group.add_option("-y", "--yes", action="store_true", \
- dest="auto_yes", \
- help="Assume Yes to all queries and do not prompt")
- download_group.add_option("-u", "--show-upgrades", \
- action="store_true", dest="upgrades", \
- help="Show a list of upgraded packages as well")
+ download_group = OptionGroup(parser, 'Download')
+ download_group.add_option('-d', '--download', action='store_true', \
+ dest='download', \
+ help='Download only - do NOT install or unpack archives')
+ download_group.add_option('-s', '--simulate', action='store_true',
+ dest='simulate', help='No-act. Perform ordering simulation')
+ download_group.add_option('-y', '--yes', action='store_true', \
+ dest='auto_yes', \
+ help='Assume Yes to all queries and do not prompt')
+ download_group.add_option('-u', '--show-upgrades', \
+ action='store_true', dest='upgrades', \
+ help='Show a list of upgraded packages as well')
parser.add_option_group(download_group)
# Not an option for 1.0
-# parser.add_option("-f", "--force", action="store_true", \
-# dest="force", \
-# help="Attempt to continue if the integrity check fails")
+# parser.add_option('-f', '--force', action='store_true', \
+# dest='force', \
+# help='Attempt to continue if the integrity check fails')
(options, arguments) = parser.parse_args(args)
if len(arguments) == 1:
self.wx_gui = True
elif len(arguments) < 3:
- parser.error("Missing the project name or command")
+ parser.error('Missing the project name or command')
if argv[2] not in command_list:
- print("Unknown command \"%s\"" % args[2])
+ print('Unknown command \'%s\'' % args[2])
# The following is used to remove the None at the end
# of the parser.print_help data
help_msg = str(parser.print_help())
- help_msg = help_msg.split("\n")
+ help_msg = help_msg.split('\n')
for index in range(len(help_msg) - 2):
print help_msg[index]
exit(1)
@@ -119,17 +119,17 @@
def execute(self):
if self.wx_gui:
- print "call GUI version"
+ print 'call GUI version'
else:
- if self.command == "create":
- definition = libkeryx.getDefinition(self.project)
- definition.OnCreate()
- if self.command == "update":
- definition = libkeryx.getDefinition(self.project)
+ if self.command == 'create':
+ definition = libkeryx.get_definition(self.project)
+ definition.on_create()
+ if self.command == 'update':
+ definition = libkeryx.get_definition(self.project)
definition.UpdateInternet()
# keryx <project-name> <command(s)> <option(s)>
-if __name__ == "__main__":
+if __name__ == '__main__':
keryx = Keryx()
no_errors = keryx.parse_options(argv)
=== modified file 'libkeryx/__init__.py'
--- libkeryx/__init__.py 2009-08-11 20:35:49 +0000
+++ libkeryx/__init__.py 2009-08-13 01:45:08 +0000
@@ -38,7 +38,7 @@
self.architecture = architecture
def __repr__(self):
- return "<gen_table('%s, %s, %s, %s')>" % (self.project, \
+ return '<gen_table(\'%s, %s, %s, %s\')>' % (self.project, \
self.definition_name, self.definition_version, self.hostname, \
self.architecture)
@@ -51,7 +51,7 @@
self.url = url
def __repr__(self):
- return "<gen_table('%s, %s, %s, %s')>" % (self.package_name, \
+ return '<gen_table(\'%s, %s, %s, %s\')>' % (self.package_name, \
self.version, self.status, self.url)
class Definition:
@@ -66,39 +66,39 @@
# Create the directory to store the downloads. Downloads
# for all projects will be stored in the same folder to
# prevent multiple downloads of the same file
- self.downloads_dir = "downloads/"
+ self.downloads_dir = 'downloads/'
if not os.path.exists(self.downloads_dir):
os.mkdir(self.downloads_dir)
# Set the database filename
- db_filename = "keryx.db"
- sql_filename = "sqlite:///" + db_filename
+ db_filename = 'keryx.db'
+ sql_filename = 'sqlite:///' + db_filename
self.engine = create_engine(sql_filename)
self.keryx_db = MetaData(self.engine)
# Define the tables that will be used for all definitions
- self.general_table = Table("general", self.keryx_db, \
- Column("project", String(40), primary_key=True), \
- Column("definition_name", String(40)), \
- Column("definition_version", Integer), \
- Column("hostname", String(256)), \
- Column("architecture", String(5)))
+ self.general_table = Table('general', self.keryx_db, \
+ Column('project', String(40), primary_key=True), \
+ Column('definition_name', String(40)), \
+ Column('definition_version', Integer), \
+ Column('hostname', String(256)), \
+ Column('architecture', String(5)))
- self.queue_table = Table("queue", self.keryx_db, \
- Column("package_name", String(40), primary_key=True), \
- Column("version", Integer, primary_key=True), \
- Column("status", String(15)), \
- Column("url", String(256)))
+ self.queue_table = Table('queue', self.keryx_db, \
+ Column('package_name', String(40), primary_key=True), \
+ Column('version', Integer, primary_key=True), \
+ Column('status', String(15)), \
+ Column('url', String(256)))
# Create the database tables
self.keryx_db.create_all()
if not os.path.exists(db_filename):
- self.__createGeneralTable()
-
- self.OnInit(self.project)
-
- def __createGeneralTable(self):
+ self.__create_general_table()
+
+ self.on_init(self.project)
+
+ def __create_general_table(self):
"""Creates the 'general' table in the database
This table contains the following columns:
definition_name - The name of the definition the project was created by
@@ -127,19 +127,19 @@
session.close()
clear_mappers()
- def OnInit(self, project):
+ def on_init(self, project):
"""Should be overridden in definition"""
pass
def create(self):
"""Create a new Keryx database"""
- self.OnCreate()
+ self.on_create()
- def OnCreate(self):
+ def on_create(self):
"""Should be overridden in definition"""
pass
- def UpdateInternet(self):
+ def update_internet(self):
"""Should be overridden in definition"""
pass
@@ -158,7 +158,7 @@
# print 'Loaded %i definitions' % len(definitions)
-def getDefinition(project):
+def get_definition(project):
""" Finds the correct definition based on the currrent OS or file """
# TODO: Make this dynamic
# Check the "keryx" table for the definition name and version
=== modified file 'libkeryx/definitions/dpkg.py'
--- libkeryx/definitions/dpkg.py 2009-08-11 18:24:30 +0000
+++ libkeryx/definitions/dpkg.py 2009-08-13 01:45:08 +0000
@@ -6,6 +6,7 @@
__author__ = 'Buran Ayuthia'
from libkeryx import Definition, gen_table, queue_table
+import gzip
import os.path
from commands import getstatusoutput
from sqlalchemy import *
@@ -43,8 +44,8 @@
self.task = task
def __repr__(self):
- return "<pkg_table('%s, %s, %s ,%s, %s, %s, %s, %s, %s, %s, %s, \
- %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s')>" % \
+ return '<pkg_table(\'%s, %s, %s ,%s, %s, %s, %s, %s, %s, %s, %s, \
+ %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s\')>' % \
(self.project, self.package_name, self.version, self.section, \
self.installed_size, self.maintainer, \
self.original_maintainer, self.architecture, self.replaces, \
@@ -54,62 +55,62 @@
self.bugs, self.origin, self.task)
class dpkg(Definition):
- """Definition for dpkg/apt support"""
+ '''Definition for dpkg/apt support'''
name = __appname__
version = __version__
- def OnInit(self, project):
+ def on_init(self, project):
# Set the project so that it can be used in other methods for
# this class
self.project = project
# The project directory
- self.project_folder_dir = "projects/"
+ self.project_folder_dir = 'projects/'
if not os.path.exists(self.project_folder_dir):
os.mkdir(self.project_folder_dir)
# Create the project in the project folder
- self.project_dir = self.project_folder_dir + self.project + "/"
+ self.project_dir = self.project_folder_dir + self.project + '/'
if not os.path.exists(self.project_dir):
os.mkdir(self.project_dir)
# Create the directory to store the package lists
# from the internet
- self.lists_dir = self.project_dir + "lists/"
+ self.lists_dir = self.project_dir + 'lists/'
if not os.path.exists(self.lists_dir):
os.mkdir(self.lists_dir)
# The location where the package lists are stored.
- self.package_list_path = "/var/lib/apt/lists/"
+ self.package_list_path = '/var/lib/apt/lists/'
Session = sessionmaker(bind=self.engine, autoflush=True, transactional=True)
self.session = Session()
# Define your definition-specific tables here
- self.packages_table = Table("packages", self.keryx_db, \
- Column("project", String(256), primary_key=True), \
- Column("package_name", String(256), primary_key=True), \
- Column("version", String(256), primary_key=True), \
- Column("section", String(256)), \
- Column("installed_size", Integer), \
- Column("maintainer", String(256)), \
- Column("original_maintainer", String(256)), \
- Column("architecture", String(256)), \
- Column("replaces", String(256)), \
- Column("provides", String(256)), \
- Column("depends", String(256)), \
- Column("recommends", String(256)), \
- Column("suggests", String(256)), \
- Column("conflicts", String(256)), \
- Column("filename", String(256)), \
- Column("size", Integer), \
- Column("md5sum", Integer), \
- Column("sha256", Integer), \
- Column("shortdesc", String(256)), \
- Column("longdesc", String(256)), \
- Column("homepage", String(256)), \
- Column("bugs", String(256)), \
- Column("origin", String(256)), \
- Column("task", String(256)))
+ self.packages_table = Table('packages', self.keryx_db, \
+ Column('project', String(256), primary_key=True), \
+ Column('package_name', String(256), primary_key=True), \
+ Column('version', String(256), primary_key=True), \
+ Column('section', String(256)), \
+ Column('installed_size', Integer), \
+ Column('maintainer', String(256)), \
+ Column('original_maintainer', String(256)), \
+ Column('architecture', String(256)), \
+ Column('replaces', String(256)), \
+ Column('provides', String(256)), \
+ Column('depends', String(256)), \
+ Column('recommends', String(256)), \
+ Column('suggests', String(256)), \
+ Column('conflicts', String(256)), \
+ Column('filename', String(256)), \
+ Column('size', Integer), \
+ Column('md5sum', Integer), \
+ Column('sha256', Integer), \
+ Column('shortdesc', String(256)), \
+ Column('longdesc', String(256)), \
+ Column('homepage', String(256)), \
+ Column('bugs', String(256)), \
+ Column('origin', String(256)), \
+ Column('task', String(256)))
self.keryx_db.create_all()
@@ -117,49 +118,49 @@
mapper(queue_table, self.queue_table)
mapper(pkg_table, self.packages_table)
- def OnCreate(self):
+ def on_create(self):
pm = PackageManager()
pm.fetch_from_local(self.package_list_path)
- def UpdateInternet(self):
+ def update_internet(self):
query = self.session.query(gen_table)
for general in self.session.query(gen_table):
print general.definition_name
pm = PackageManager()
- pm.fetch_from_internet(["a", "b"], "lists")
+ pm.fetch_from_internet(['a', 'b'], 'lists')
class PackageManager:
def __init__(self):
pass
def fetch_from_local(self, list_path):
- print "fetching from local"
+ print 'fetching from local'
# No longer going to be storing the local data
# # Check to see if the dest_path directory exists
# if not os.path.isdir(dest_path):
-# print "pkgmgr.py: Directory \"%s\" does not exist. Cannot copy files." % dest_path
+# print 'pkgmgr.py: Directory \'%s\' does not exist. Cannot copy files.' % dest_path
# return None
#
# # Copy files if list_path directory exists
# if os.path.isdir(list_path):
# dir_list = os.listdir(list_path)
# for file in dir_list:
-# test_file = list_path + "/" + file
-# if os.path.isfile(test_file) and file != "lock":
-# copy_string = "cp -v %s %s" % (test_file, dest_path)
+# test_file = list_path + '/' + file
+# if os.path.isfile(test_file) and file != 'lock':
+# copy_string = 'cp -v %s %s' % (test_file, dest_path)
# copy_value = getstatusoutput(copy_string)
# if not copy_value:
-# print "pkgmgr.py: Unable to copy %s. " \
-# "Error code= %d Error message=%s" % \
+# print 'pkgmgr.py: Unable to copy %s. ' \
+# 'Error code= %d Error message=%s' % \
# (test_file, copy_value[0], copy_value[1])
# return None
# else:
-# print file + " copied."
+# print file + ' copied.'
# else:
-# print "pkgmgr.py: Could not find list_path %s" % list_path
+# print 'pkgmgr.py: Could not find list_path %s' % list_path
# return None
def fetch_from_internet(self, url_list, dest_path):
- print "fetch_from_internet"
+ print 'fetch_from_internet'
References