* add a nice toy called pisish, for those people who issue one pisi

command after the other (yes, it will have more features as requested)
This commit is contained in:
Eray Özkural
2006-06-07 19:23:55 +00:00
parent ea04b18c0a
commit cd16c08452
5 changed files with 161 additions and 68 deletions
+6 -6
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-3.8.dtd"> <!DOCTYPE Project SYSTEM "Project-3.8.dtd">
<!-- Project file for project pisi --> <!-- Project file for project pisi -->
<!-- Saved: 2006-05-25, 16:13:51 --> <!-- Saved: 2006-06-07, 18:20:43 -->
<!-- Copyright (C) 2006 PiSi Development Team, --> <!-- Copyright (C) 2006 PiSi Development Team, -->
<Project version="3.8"> <Project version="3.8">
<ProgLanguage mixed="0">Python</ProgLanguage> <ProgLanguage mixed="0">Python</ProgLanguage>
@@ -446,10 +446,6 @@
<Dir>tests</Dir> <Dir>tests</Dir>
<Name>conflicttests.py</Name> <Name>conflicttests.py</Name>
</Source> </Source>
<Source>
<Dir>tests</Dir>
<Name>zipfileexttests.py</Name>
</Source>
<Source> <Source>
<Dir>pisi</Dir> <Dir>pisi</Dir>
<Name>environment.py</Name> <Name>environment.py</Name>
@@ -569,6 +565,10 @@
<Dir>scripts</Dir> <Dir>scripts</Dir>
<Name>lspisi</Name> <Name>lspisi</Name>
</Source> </Source>
<Source>
<Dir>scripts</Dir>
<Name>pisish</Name>
</Source>
</Sources> </Sources>
<Forms> <Forms>
</Forms> </Forms>
@@ -613,7 +613,7 @@
<FiletypeAssociation pattern="*.ui.h" type="FORMS" /> <FiletypeAssociation pattern="*.ui.h" type="FORMS" />
<FiletypeAssociation pattern="*.ui" type="FORMS" /> <FiletypeAssociation pattern="*.ui" type="FORMS" />
<FiletypeAssociation pattern="*.idl" type="INTERFACES" /> <FiletypeAssociation pattern="*.idl" type="INTERFACES" />
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
<FiletypeAssociation pattern="*.py" type="SOURCES" /> <FiletypeAssociation pattern="*.py" type="SOURCES" />
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
</FiletypeAssociations> </FiletypeAssociations>
</Project> </Project>
+58 -58
View File
@@ -54,10 +54,10 @@ class Command(object):
return s return s
@staticmethod @staticmethod
def get_command(cmd, fail=False): def get_command(cmd, fail=False, args=None):
if Command.cmd_dict.has_key(cmd): if Command.cmd_dict.has_key(cmd):
return Command.cmd_dict[cmd]() return Command.cmd_dict[cmd](args)
if fail: if fail:
raise Error(_("Unrecognized command: %s") % cmd) raise Error(_("Unrecognized command: %s") % cmd)
@@ -66,7 +66,7 @@ class Command(object):
# instance variabes # instance variabes
def __init__(self): def __init__(self, args = None):
# now for the real parser # now for the real parser
import pisi import pisi
self.comar = False self.comar = False
@@ -74,7 +74,7 @@ class Command(object):
version="%prog " + pisi.__version__) version="%prog " + pisi.__version__)
self.options() self.options()
self.commonopts() self.commonopts()
(self.options, self.args) = self.parser.parse_args() (self.options, self.args) = self.parser.parse_args(args)
if self.args: if self.args:
self.args.pop(0) # exclude command arg self.args.pop(0) # exclude command arg
@@ -203,11 +203,11 @@ If run without parameters, it prints the general help."""
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args = None):
#TODO? Discard Help's own usage doc in favor of general usage doc #TODO? Discard Help's own usage doc in favor of general usage doc
#self.__doc__ = usage_text #self.__doc__ = usage_text
#self.__doc__ += commands_string() #self.__doc__ += commands_string()
super(Help, self).__init__() super(Help, self).__init__(args)
name = ("help", "?") name = ("help", "?")
@@ -238,8 +238,8 @@ This command deletes unused locks from the database directory."""
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args=None):
super(Clean, self).__init__() super(Clean, self).__init__(args)
name = ("clean", None) name = ("clean", None)
@@ -260,8 +260,8 @@ consume a lot of disk space."""
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args=None):
super(DeleteCache, self).__init__() super(DeleteCache, self).__init__(args)
name = ("delete-cache", "dc") name = ("delete-cache", "dc")
@@ -283,8 +283,8 @@ the package in graphviz format to 'pgraph.dot'.
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args=None):
super(Graph, self).__init__() super(Graph, self).__init__(args)
def options(self): def options(self):
self.parser.add_option("-r", "--repository", action="store", self.parser.add_option("-r", "--repository", action="store",
@@ -364,8 +364,8 @@ unpack, setup, build, install, package.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(Build, self).__init__() super(Build, self).__init__(args)
name = ("build", "bi") name = ("build", "bi")
@@ -440,8 +440,8 @@ downloaded from a repository containing sources.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(Emerge, self).__init__() super(Emerge, self).__init__(args)
self.comar = True self.comar = True
name = ("emerge", "em") name = ("emerge", "em")
@@ -470,8 +470,8 @@ downloaded from a repository containing sources.
class PackageOp(Command): class PackageOp(Command):
"""Abstract package operation command""" """Abstract package operation command"""
def __init__(self): def __init__(self, args):
super(PackageOp, self).__init__() super(PackageOp, self).__init__(args)
self.comar = True self.comar = True
def options(self): def options(self):
@@ -507,8 +507,8 @@ expanded to package names.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(Install, self).__init__() super(Install, self).__init__(args)
name = "install", "it" name = "install", "it"
@@ -552,8 +552,8 @@ expanded to package names.
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(Upgrade, self).__init__() super(Upgrade, self).__init__(args)
name = ("upgrade", "up") name = ("upgrade", "up")
@@ -602,8 +602,8 @@ expanded to package names.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(Remove, self).__init__() super(Remove, self).__init__(args)
name = ("remove", "rm") name = ("remove", "rm")
@@ -628,8 +628,8 @@ configures those packages.
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(ConfigurePending, self).__init__() super(ConfigurePending, self).__init__(args)
name = ("configure-pending", "cp") name = ("configure-pending", "cp")
@@ -649,8 +649,8 @@ Usage: info <package1> <package2> ... <packagen>
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(Info, self).__init__() super(Info, self).__init__(args)
name = ("info", None) name = ("info", None)
@@ -743,8 +743,8 @@ Just give the names of packages.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(Check, self).__init__() super(Check, self).__init__(args)
name = ("check", None) name = ("check", None)
@@ -777,8 +777,8 @@ everything in a single index file.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(Index, self).__init__() super(Index, self).__init__(args)
name = ("index", "ix") name = ("index", "ix")
@@ -825,8 +825,8 @@ Usage: list-installed
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(ListInstalled, self).__init__() super(ListInstalled, self).__init__(args)
name = ("list-installed", "li") name = ("list-installed", "li")
@@ -867,8 +867,8 @@ dirs under /var/lib/pisi
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(RebuildDb, self).__init__() super(RebuildDb, self).__init__(args)
name = ("rebuild-db", "rdb") name = ("rebuild-db", "rdb")
@@ -901,8 +901,8 @@ If no repository is given, all repositories are updated.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self,args):
super(UpdateRepo, self).__init__() super(UpdateRepo, self).__init__(args)
name = ("update-repo", "ur") name = ("update-repo", "ur")
@@ -938,8 +938,8 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(AddRepo, self).__init__() super(AddRepo, self).__init__(args)
name = ("add-repo", "ar") name = ("add-repo", "ar")
@@ -971,8 +971,8 @@ Remove all repository information from the system.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self,args):
super(RemoveRepo, self).__init__() super(RemoveRepo, self).__init__(args)
name = ("remove-repo", "rr") name = ("remove-repo", "rr")
@@ -997,8 +997,8 @@ Lists currently tracked repositories.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(ListRepo, self).__init__() super(ListRepo, self).__init__(args)
name = ("list-repo", "lr") name = ("list-repo", "lr")
@@ -1022,8 +1022,8 @@ all repositories.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(ListAvailable, self).__init__() super(ListAvailable, self).__init__(args)
name = ("list-available", "la") name = ("list-available", "la")
@@ -1079,8 +1079,8 @@ repositories.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(ListComponents, self).__init__() super(ListComponents, self).__init__(args)
name = ("list-components", "lc") name = ("list-components", "lc")
@@ -1116,8 +1116,8 @@ Gives a brief list of sources published in the repositories.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(ListSources, self).__init__() super(ListSources, self).__init__(args)
name = ("list-sources", "ls") name = ("list-sources", "ls")
@@ -1153,8 +1153,8 @@ Lists the packages that will be upgraded.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(ListUpgrades, self).__init__() super(ListUpgrades, self).__init__(args)
name = ("list-upgrades", "lu") name = ("list-upgrades", "lu")
@@ -1195,8 +1195,8 @@ Lists packages waiting to be configured.
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(ListPending, self).__init__() super(ListPending, self).__init__(args)
name = ("list-pending", "lp") name = ("list-pending", "lp")
@@ -1219,8 +1219,8 @@ in summary, description, and package name fields.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(Search, self).__init__() super(Search, self).__init__(args)
name = ("search", "sr") name = ("search", "sr")
@@ -1266,8 +1266,8 @@ Finds the installed package which contains the specified file.
""" """
__metaclass__ = autocommand __metaclass__ = autocommand
def __init__(self): def __init__(self, args):
super(SearchFile, self).__init__() super(SearchFile, self).__init__(args)
name = ("search-file", "sf") name = ("search-file", "sf")
+3 -3
View File
@@ -82,13 +82,13 @@ class PreParser(OptionParser):
class PisiCLI(object): class PisiCLI(object):
def __init__(self): def __init__(self, args=None):
# first construct a parser for common options # first construct a parser for common options
# this is really dummy # this is really dummy
self.parser = PreParser(version="%prog " + pisi.__version__) self.parser = PreParser(version="%prog " + pisi.__version__)
try: try:
opts, args = self.parser.parse_args() opts, args = self.parser.parse_args(args=args)
if len(args)==0: # more explicit than using IndexError if len(args)==0: # more explicit than using IndexError
if 'version' in opts: if 'version' in opts:
self.parser.print_version() self.parser.print_version()
@@ -100,7 +100,7 @@ class PisiCLI(object):
except ParserError: except ParserError:
raise Error(_('Command line parsing error')) raise Error(_('Command line parsing error'))
self.command = Command.get_command(cmd_name) self.command = Command.get_command(cmd_name, args)
if not self.command: if not self.command:
raise Error(_("Unrecognized command: %s") % cmd_name) raise Error(_("Unrecognized command: %s") % cmd_name)
Executable
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/python
#
# Copyright (C) 2005, TUBITAK/UEKAE
#
# 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 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
# Authors: Eray, Baris
import sys
import locale
import traceback
import exceptions
import signal
import bsddb3.db as db
import os
import pisi.ui
import pisi.context as ctx
from pisi.cli.pisicli import PisiCLI
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
def exit(retval = 0):
pisi.api.finalize()
sys.exit(retval)
if __name__ == "__main__":
locale.setlocale(locale.LC_ALL, '')
print """Welcome to the interactive PISI shell.
Type "help" to see a list of commands.
To end the session, type "exit".
Copyright 2006 (c) Pardus
"""
while 1:
cmd = raw_input('pisi> ')
if cmd.strip()=='exit':
print 'Bye!'
exit()
if cmd.startswith('!'):
cmd = cmd[1:]
os.system(cmd)
continue
try:
cli = PisiCLI(cmd.split())
cli.run_command()
except pisi.operations.PisiUpgradeException, e:
print _('PISI has been upgraded.')
except Exception, value:
signal.signal(signal.SIGINT, signal.SIG_IGN) # disable further interrupts
ui = pisi.cli.CLI() # make a temporary UI
show_traceback = False
if isinstance(value, exceptions.KeyboardInterrupt):
ui.error(_("Keyboard Interrupt: Exiting..."))
pisi.api.finalize()
sys.exit(1)
elif isinstance(value, pisi.Error):
ui.error(_("Program Terminated."))
show_traceback = ctx.get_option('debug')
elif isinstance(value, db.DBRunRecoveryError):
ui.error(_("""A database operation has been aborted. You should run pisi
again for normal DB recovery procedure. Make sure you have free disk space.
You have to run rebuild-db only when there is file corruption and database upgrades."""))
elif isinstance(value, pisi.Exception):
show_traceback = True
ui.error(_("""Unhandled internal exception.
Please file a bug report. (http://bugs.uludag.org.tr)"""))
else:
# For any other exception (possibly Python exceptions) show
# the traceback!
show_traceback = ctx.get_option('debug')
ui.error(_("System Error. Program Terminated."))
if ctx.get_option('debug'):
ui.error(u"%s: %s" % (exception, value))
else:
ui.error(unicode(value))
ui.info(_("Please use 'pisi help' for general help."))
if show_traceback:
ui.info(_("Traceback:"))
traceback.print_tb(tb)
else:
ui.info(_("Use --debug to see a traceback."))
+1 -1
View File
@@ -95,7 +95,7 @@ setup(name="pisi",
packages = ['pisi', 'pisi.cli', 'pisi.actionsapi', 'pisi.pxml', 'pisi.search'], packages = ['pisi', 'pisi.cli', 'pisi.actionsapi', 'pisi.pxml', 'pisi.search'],
scripts = ['pisi-cli', 'scripts/repostats.py', 'scripts/find-lib-deps.py', scripts = ['pisi-cli', 'scripts/repostats.py', 'scripts/find-lib-deps.py',
'scripts/update-environ.py', 'scripts/lspisi', 'scripts/unpisi', 'scripts/update-environ.py', 'scripts/lspisi', 'scripts/unpisi',
'scripts/calc-build-order.py'], 'scripts/calc-build-order.py', 'scripts/pisish'],
cmdclass = { cmdclass = {
'install' : Install 'install' : Install
} }