Kaydet (Commit) cd16c084 authored tarafından Eray Özkural's avatar Eray Özkural

* 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)
üst ea04b18c
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Project SYSTEM "Project-3.8.dtd">
<!-- 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, -->
<Project version="3.8">
<ProgLanguage mixed="0">Python</ProgLanguage>
......@@ -446,10 +446,6 @@
<Dir>tests</Dir>
<Name>conflicttests.py</Name>
</Source>
<Source>
<Dir>tests</Dir>
<Name>zipfileexttests.py</Name>
</Source>
<Source>
<Dir>pisi</Dir>
<Name>environment.py</Name>
......@@ -569,6 +565,10 @@
<Dir>scripts</Dir>
<Name>lspisi</Name>
</Source>
<Source>
<Dir>scripts</Dir>
<Name>pisish</Name>
</Source>
</Sources>
<Forms>
</Forms>
......@@ -613,7 +613,7 @@
<FiletypeAssociation pattern="*.ui.h" type="FORMS" />
<FiletypeAssociation pattern="*.ui" type="FORMS" />
<FiletypeAssociation pattern="*.idl" type="INTERFACES" />
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
<FiletypeAssociation pattern="*.py" type="SOURCES" />
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
</FiletypeAssociations>
</Project>
......@@ -54,10 +54,10 @@ class Command(object):
return s
@staticmethod
def get_command(cmd, fail=False):
def get_command(cmd, fail=False, args=None):
if Command.cmd_dict.has_key(cmd):
return Command.cmd_dict[cmd]()
return Command.cmd_dict[cmd](args)
if fail:
raise Error(_("Unrecognized command: %s") % cmd)
......@@ -66,7 +66,7 @@ class Command(object):
# instance variabes
def __init__(self):
def __init__(self, args = None):
# now for the real parser
import pisi
self.comar = False
......@@ -74,7 +74,7 @@ class Command(object):
version="%prog " + pisi.__version__)
self.options()
self.commonopts()
(self.options, self.args) = self.parser.parse_args()
(self.options, self.args) = self.parser.parse_args(args)
if self.args:
self.args.pop(0) # exclude command arg
......@@ -203,11 +203,11 @@ If run without parameters, it prints the general help."""
__metaclass__ = autocommand
def __init__(self):
def __init__(self, args = None):
#TODO? Discard Help's own usage doc in favor of general usage doc
#self.__doc__ = usage_text
#self.__doc__ += commands_string()
super(Help, self).__init__()
super(Help, self).__init__(args)
name = ("help", "?")
......@@ -238,8 +238,8 @@ This command deletes unused locks from the database directory."""
__metaclass__ = autocommand
def __init__(self):
super(Clean, self).__init__()
def __init__(self, args=None):
super(Clean, self).__init__(args)
name = ("clean", None)
......@@ -260,8 +260,8 @@ consume a lot of disk space."""
__metaclass__ = autocommand
def __init__(self):
super(DeleteCache, self).__init__()
def __init__(self, args=None):
super(DeleteCache, self).__init__(args)
name = ("delete-cache", "dc")
......@@ -283,8 +283,8 @@ the package in graphviz format to 'pgraph.dot'.
__metaclass__ = autocommand
def __init__(self):
super(Graph, self).__init__()
def __init__(self, args=None):
super(Graph, self).__init__(args)
def options(self):
self.parser.add_option("-r", "--repository", action="store",
......@@ -364,8 +364,8 @@ unpack, setup, build, install, package.
"""
__metaclass__ = autocommand
def __init__(self):
super(Build, self).__init__()
def __init__(self, args):
super(Build, self).__init__(args)
name = ("build", "bi")
......@@ -440,8 +440,8 @@ downloaded from a repository containing sources.
"""
__metaclass__ = autocommand
def __init__(self):
super(Emerge, self).__init__()
def __init__(self, args):
super(Emerge, self).__init__(args)
self.comar = True
name = ("emerge", "em")
......@@ -470,8 +470,8 @@ downloaded from a repository containing sources.
class PackageOp(Command):
"""Abstract package operation command"""
def __init__(self):
super(PackageOp, self).__init__()
def __init__(self, args):
super(PackageOp, self).__init__(args)
self.comar = True
def options(self):
......@@ -507,8 +507,8 @@ expanded to package names.
"""
__metaclass__ = autocommand
def __init__(self):
super(Install, self).__init__()
def __init__(self, args):
super(Install, self).__init__(args)
name = "install", "it"
......@@ -552,8 +552,8 @@ expanded to package names.
__metaclass__ = autocommand
def __init__(self):
super(Upgrade, self).__init__()
def __init__(self, args):
super(Upgrade, self).__init__(args)
name = ("upgrade", "up")
......@@ -602,8 +602,8 @@ expanded to package names.
"""
__metaclass__ = autocommand
def __init__(self):
super(Remove, self).__init__()
def __init__(self, args):
super(Remove, self).__init__(args)
name = ("remove", "rm")
......@@ -628,8 +628,8 @@ configures those packages.
__metaclass__ = autocommand
def __init__(self):
super(ConfigurePending, self).__init__()
def __init__(self, args):
super(ConfigurePending, self).__init__(args)
name = ("configure-pending", "cp")
......@@ -649,8 +649,8 @@ Usage: info <package1> <package2> ... <packagen>
"""
__metaclass__ = autocommand
def __init__(self):
super(Info, self).__init__()
def __init__(self, args):
super(Info, self).__init__(args)
name = ("info", None)
......@@ -743,8 +743,8 @@ Just give the names of packages.
"""
__metaclass__ = autocommand
def __init__(self):
super(Check, self).__init__()
def __init__(self, args):
super(Check, self).__init__(args)
name = ("check", None)
......@@ -777,8 +777,8 @@ everything in a single index file.
"""
__metaclass__ = autocommand
def __init__(self):
super(Index, self).__init__()
def __init__(self, args):
super(Index, self).__init__(args)
name = ("index", "ix")
......@@ -825,8 +825,8 @@ Usage: list-installed
__metaclass__ = autocommand
def __init__(self):
super(ListInstalled, self).__init__()
def __init__(self, args):
super(ListInstalled, self).__init__(args)
name = ("list-installed", "li")
......@@ -867,8 +867,8 @@ dirs under /var/lib/pisi
"""
__metaclass__ = autocommand
def __init__(self):
super(RebuildDb, self).__init__()
def __init__(self, args):
super(RebuildDb, self).__init__(args)
name = ("rebuild-db", "rdb")
......@@ -901,8 +901,8 @@ If no repository is given, all repositories are updated.
"""
__metaclass__ = autocommand
def __init__(self):
super(UpdateRepo, self).__init__()
def __init__(self,args):
super(UpdateRepo, self).__init__(args)
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
def __init__(self):
super(AddRepo, self).__init__()
def __init__(self, args):
super(AddRepo, self).__init__(args)
name = ("add-repo", "ar")
......@@ -971,8 +971,8 @@ Remove all repository information from the system.
"""
__metaclass__ = autocommand
def __init__(self):
super(RemoveRepo, self).__init__()
def __init__(self,args):
super(RemoveRepo, self).__init__(args)
name = ("remove-repo", "rr")
......@@ -997,8 +997,8 @@ Lists currently tracked repositories.
"""
__metaclass__ = autocommand
def __init__(self):
super(ListRepo, self).__init__()
def __init__(self, args):
super(ListRepo, self).__init__(args)
name = ("list-repo", "lr")
......@@ -1022,8 +1022,8 @@ all repositories.
"""
__metaclass__ = autocommand
def __init__(self):
super(ListAvailable, self).__init__()
def __init__(self, args):
super(ListAvailable, self).__init__(args)
name = ("list-available", "la")
......@@ -1079,8 +1079,8 @@ repositories.
"""
__metaclass__ = autocommand
def __init__(self):
super(ListComponents, self).__init__()
def __init__(self, args):
super(ListComponents, self).__init__(args)
name = ("list-components", "lc")
......@@ -1116,8 +1116,8 @@ Gives a brief list of sources published in the repositories.
"""
__metaclass__ = autocommand
def __init__(self):
super(ListSources, self).__init__()
def __init__(self, args):
super(ListSources, self).__init__(args)
name = ("list-sources", "ls")
......@@ -1153,8 +1153,8 @@ Lists the packages that will be upgraded.
"""
__metaclass__ = autocommand
def __init__(self):
super(ListUpgrades, self).__init__()
def __init__(self, args):
super(ListUpgrades, self).__init__(args)
name = ("list-upgrades", "lu")
......@@ -1195,8 +1195,8 @@ Lists packages waiting to be configured.
__metaclass__ = autocommand
def __init__(self):
super(ListPending, self).__init__()
def __init__(self, args):
super(ListPending, self).__init__(args)
name = ("list-pending", "lp")
......@@ -1219,8 +1219,8 @@ in summary, description, and package name fields.
"""
__metaclass__ = autocommand
def __init__(self):
super(Search, self).__init__()
def __init__(self, args):
super(Search, self).__init__(args)
name = ("search", "sr")
......@@ -1266,8 +1266,8 @@ Finds the installed package which contains the specified file.
"""
__metaclass__ = autocommand
def __init__(self):
super(SearchFile, self).__init__()
def __init__(self, args):
super(SearchFile, self).__init__(args)
name = ("search-file", "sf")
......
......@@ -82,13 +82,13 @@ class PreParser(OptionParser):
class PisiCLI(object):
def __init__(self):
def __init__(self, args=None):
# first construct a parser for common options
# this is really dummy
self.parser = PreParser(version="%prog " + pisi.__version__)
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 'version' in opts:
self.parser.print_version()
......@@ -100,7 +100,7 @@ class PisiCLI(object):
except ParserError:
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:
raise Error(_("Unrecognized command: %s") % cmd_name)
......
#!/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."))
......@@ -95,7 +95,7 @@ setup(name="pisi",
packages = ['pisi', 'pisi.cli', 'pisi.actionsapi', 'pisi.pxml', 'pisi.search'],
scripts = ['pisi-cli', 'scripts/repostats.py', 'scripts/find-lib-deps.py',
'scripts/update-environ.py', 'scripts/lspisi', 'scripts/unpisi',
'scripts/calc-build-order.py'],
'scripts/calc-build-order.py', 'scripts/pisish'],
cmdclass = {
'install' : Install
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment