2009-03-02 15:03:06 +01:00
# Copyright (C) 2006 Novell Inc. All rights reserved.
2006-04-20 16:26:50 +02:00
# This program is free software; it may be used, copied, modified
# and distributed under the terms of the GNU General Public Licence,
2009-08-20 21:28:05 +02:00
# either version 2, or version 3 (at your option).
2006-04-20 16:26:50 +02:00
2006-05-23 15:48:58 +02:00
2006-05-10 16:34:59 +02:00
from core import *
2007-04-25 01:00:12 +02:00
import cmdln
2006-10-10 16:04:34 +02:00
import conf
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
import oscerr
2010-02-09 21:22:32 +01:00
import urlgrabber . progress
2010-01-20 09:15:17 +01:00
from optparse import SUPPRESS_HELP
2006-04-20 16:26:50 +02:00
2009-05-06 15:20:15 +02:00
MAN_HEADER = r """ .TH %(ucname)s " 1 " " %(date)s " " %(name)s %(version)s " " User Commands "
. SH NAME
2009-06-17 20:19:45 +02:00
% ( name ) s \- openSUSE build service command - line tool .
2009-05-06 15:20:15 +02:00
. SH SYNOPSIS
. B % ( name ) s
[ \fIGLOBALOPTS \fR ] \fISUBCOMMAND \fR [ \fIOPTS \fR ] [ \fIARGS \fR . . . ]
. br
. B % ( name ) s
\fIhelp SUBCOMMAND \fR
. SH DESCRIPTION
2009-06-17 20:19:45 +02:00
openSUSE build service command - line tool .
2009-05-06 15:20:15 +02:00
"""
MAN_FOOTER = r """
. SH " SEE ALSO "
Type ' osc help <subcommand> ' for more detailed help on a specific subcommand .
. PP
For additional information , see
2010-02-27 20:14:25 +01:00
* http : / / en . opensuse . org / Build_Service_Tutorial
* http : / / en . opensuse . org / Build_Service / CLI
2009-05-06 15:20:15 +02:00
. PP
You can modify osc commands , or roll you own , via the plugin API :
2010-02-27 20:14:25 +01:00
* http : / / en . opensuse . org / Build_Service / osc_plugins
2009-05-06 15:20:15 +02:00
. SH AUTHOR
osc was written by several authors . This man page is automatically generated .
"""
2007-04-25 01:00:12 +02:00
class Osc ( cmdln . Cmdln ) :
2009-05-05 16:13:22 +02:00
""" Usage: osc [GLOBALOPTS] SUBCOMMAND [OPTS] [ARGS...]
or : osc help SUBCOMMAND
2009-06-17 20:19:45 +02:00
openSUSE build service command - line tool .
2007-04-25 01:00:12 +02:00
Type ' osc help <subcommand> ' for help on a specific subcommand .
2006-12-12 03:01:39 +01:00
2007-04-25 01:00:12 +02:00
$ { command_list }
$ { help_list }
global $ { option_list }
2009-05-18 16:50:43 +02:00
For additional information , see
2010-02-27 20:14:25 +01:00
* http : / / en . opensuse . org / Build_Service_Tutorial
* http : / / en . opensuse . org / Build_Service / CLI
2008-09-24 14:23:56 +02:00
You can modify osc commands , or roll you own , via the plugin API :
2010-02-27 20:14:25 +01:00
* http : / / en . opensuse . org / Build_Service / osc_plugins
2007-04-25 01:00:12 +02:00
"""
name = ' osc '
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
conf = None
2006-12-12 03:01:39 +01:00
2009-05-06 15:20:15 +02:00
man_header = MAN_HEADER
man_footer = MAN_FOOTER
2007-05-16 12:55:05 +02:00
2007-04-25 01:00:12 +02:00
def __init__ ( self , * args , * * kwargs ) :
cmdln . Cmdln . __init__ ( self , * args , * * kwargs )
cmdln . Cmdln . do_help . aliases . append ( ' h ' )
2006-05-23 15:48:58 +02:00
2009-05-06 15:20:15 +02:00
def get_version ( self ) :
return get_osc_version ( )
2007-05-16 12:55:05 +02:00
def get_optparser ( self ) :
""" this is the parser for " global " options (not specific to subcommand) """
optparser = cmdln . CmdlnOptionParser ( self , version = get_osc_version ( ) )
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
optparser . add_option ( ' --debugger ' , action = ' store_true ' ,
help = ' jump into the debugger before executing anything ' )
optparser . add_option ( ' --post-mortem ' , action = ' store_true ' ,
help = ' jump into the debugger in case of errors ' )
optparser . add_option ( ' -t ' , ' --traceback ' , action = ' store_true ' ,
help = ' print call trace in case of errors ' )
2007-05-16 12:55:05 +02:00
optparser . add_option ( ' -H ' , ' --http-debug ' , action = ' store_true ' ,
2007-04-25 01:00:12 +02:00
help = ' debug HTTP traffic ' )
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
optparser . add_option ( ' -d ' , ' --debug ' , action = ' store_true ' ,
help = ' print info useful for debugging ' )
2009-02-24 00:29:32 +01:00
optparser . add_option ( ' -A ' , ' --apiurl ' , dest = ' apiurl ' ,
2009-03-31 15:29:16 +02:00
metavar = ' URL/alias ' ,
help = ' specify URL to access API server at or an alias ' )
2007-08-22 12:18:25 +02:00
optparser . add_option ( ' -c ' , ' --config ' , dest = ' conffile ' ,
metavar = ' FILE ' ,
help = ' specify alternate configuration file ' )
2009-09-04 19:48:53 +02:00
optparser . add_option ( ' --no-keyring ' , action = ' store_true ' ,
help = ' disable usage of desktop keyring system ' )
2009-05-11 09:46:01 +02:00
optparser . add_option ( ' --no-gnome-keyring ' , action = ' store_true ' ,
help = ' disable usage of GNOME Keyring ' )
2009-08-20 21:28:05 +02:00
optparser . add_option ( ' -v ' , ' --verbose ' , dest = ' verbose ' , action = ' count ' , default = 0 ,
help = ' increase verbosity ' )
optparser . add_option ( ' -q ' , ' --quiet ' , dest = ' verbose ' , action = ' store_const ' , const = - 1 ,
help = ' be quiet, not verbose ' )
2007-05-16 12:55:05 +02:00
return optparser
2006-05-23 15:48:58 +02:00
2008-08-20 11:40:00 +02:00
def postoptparse ( self , try_again = True ) :
2007-05-16 12:55:05 +02:00
""" merge commandline options into the config """
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
try :
conf . get_config ( override_conffile = self . options . conffile ,
2009-02-24 00:29:32 +01:00
override_apiurl = self . options . apiurl ,
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
override_debug = self . options . debug ,
override_http_debug = self . options . http_debug ,
override_traceback = self . options . traceback ,
2009-05-11 09:46:01 +02:00
override_post_mortem = self . options . post_mortem ,
2009-09-04 19:48:53 +02:00
override_no_keyring = self . options . no_keyring ,
2009-08-20 21:28:05 +02:00
override_no_gnome_keyring = self . options . no_gnome_keyring ,
override_verbose = self . options . verbose )
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
except oscerr . NoConfigfile , e :
print >> sys . stderr , e . msg
print >> sys . stderr , ' Creating osc configuration file %s ... ' % e . file
import getpass
config = { }
config [ ' user ' ] = raw_input ( ' Username: ' )
config [ ' pass ' ] = getpass . getpass ( )
2010-02-25 14:13:02 +01:00
if self . options . no_keyring :
config [ ' use_keyring ' ] = ' 0 '
if self . options . no_gnome_keyring :
config [ ' gnome_keyring ' ] = ' 0 '
2009-02-24 00:29:32 +01:00
if self . options . apiurl :
config [ ' apiurl ' ] = self . options . apiurl
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
2008-08-21 20:17:40 +02:00
conf . write_initial_config ( e . file , config )
2008-08-07 18:40:55 +02:00
print >> sys . stderr , ' done '
2008-08-20 11:40:00 +02:00
if try_again : self . postoptparse ( try_again = False )
2008-08-07 19:14:26 +02:00
except oscerr . ConfigMissingApiurl , e :
print >> sys . stderr , e . msg
import getpass
user = raw_input ( ' Username: ' )
passwd = getpass . getpass ( )
2009-05-11 09:46:01 +02:00
conf . add_section ( e . file , e . url , user , passwd )
2008-08-20 11:40:00 +02:00
if try_again : self . postoptparse ( try_again = False )
2008-08-07 19:14:26 +02:00
2009-08-20 21:28:05 +02:00
self . options . verbose = conf . config [ ' verbose ' ]
2010-02-09 20:57:10 +01:00
self . download_progress = None
if conf . config . get ( ' show_download_progress ' , False ) :
2010-02-24 11:27:18 +01:00
from meter import TextMeter
self . download_progress = TextMeter ( )
2006-05-23 15:48:58 +02:00
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
def get_cmd_help ( self , cmdname ) :
doc = self . _get_cmd_handler ( cmdname ) . __doc__
doc = self . _help_reindent ( doc )
doc = self . _help_preprocess ( doc , cmdname )
doc = doc . rstrip ( ) + ' \n ' # trim down trailing space
return self . _str ( doc )
2006-04-20 16:26:50 +02:00
2009-08-21 16:55:26 +02:00
# overridden from class Cmdln() to use config variables in help texts
def _help_preprocess ( self , help , cmdname ) :
help = cmdln . Cmdln . _help_preprocess ( self , help , cmdname )
2009-08-21 02:42:51 +02:00
return help % conf . config
2006-04-20 16:26:50 +02:00
2009-08-21 16:55:26 +02:00
2008-08-08 17:19:54 +02:00
def do_init ( self , subcmd , opts , project , package = None ) :
2009-05-18 16:50:43 +02:00
""" $ {cmd_name} : Initialize a directory as working copy
2006-05-23 15:48:58 +02:00
2008-05-21 18:10:20 +02:00
Initialize an existing directory to be a working copy of an
2009-05-18 16:50:43 +02:00
( already existing ) buildservice project / package .
2008-05-21 18:10:20 +02:00
( This is the same as checking out a package and then copying sources
into the directory . It does NOT create a new package . To create a
package , use ' osc meta pkg ... ... ' )
2006-05-23 15:48:58 +02:00
2008-05-21 18:10:20 +02:00
You wouldn ' t normally use this command.
To get a working copy of a package ( e . g . for building it or working on
it , you would normally use the checkout command . Use " osc help
checkout " to get help for it.
2009-05-18 16:50:43 +02:00
usage :
2008-08-01 15:58:49 +02:00
osc init PRJ
2007-06-21 11:40:47 +02:00
osc init PRJ PAC
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2009-05-18 16:50:43 +02:00
2008-08-08 17:19:54 +02:00
if not package :
init_project_dir ( conf . config [ ' apiurl ' ] , os . curdir , project )
print ' Initializing %s (Project: %s ) ' % ( os . curdir , project )
2008-08-01 15:58:49 +02:00
else :
2008-08-08 17:19:54 +02:00
init_package_dir ( conf . config [ ' apiurl ' ] , project , package , os . path . curdir )
print ' Initializing %s (Project: %s , Package: %s ) ' % ( os . curdir , project , package )
2007-04-25 01:00:12 +02:00
@cmdln.alias ( ' ls ' )
2009-08-20 21:28:05 +02:00
@cmdln.alias ( ' ll ' )
@cmdln.alias ( ' lL ' )
@cmdln.alias ( ' LL ' )
2007-08-16 20:15:08 +02:00
@cmdln.option ( ' -a ' , ' --arch ' , metavar = ' ARCH ' ,
2010-01-12 13:31:25 +01:00
help = ' specify architecture (only for binaries) ' )
2007-08-16 20:15:08 +02:00
@cmdln.option ( ' -r ' , ' --repo ' , metavar = ' REPO ' ,
2010-01-12 13:31:25 +01:00
help = ' specify repository (only for binaries) ' )
2007-08-16 20:15:08 +02:00
@cmdln.option ( ' -b ' , ' --binaries ' , action = ' store_true ' ,
2010-01-12 13:31:25 +01:00
help = ' list built binaries instead of sources ' )
@cmdln.option ( ' -R ' , ' --revision ' , metavar = ' REVISION ' ,
help = ' specify revision (only for sources) ' )
@cmdln.option ( ' -e ' , ' --expand ' , action = ' store_true ' ,
help = ' expand linked package (only for sources) ' )
2010-03-08 23:52:51 +01:00
@cmdln.option ( ' -u ' , ' --unexpand ' , action = ' store_true ' ,
help = ' always work with unexpanded (source) packages ' )
2007-06-26 15:17:38 +02:00
@cmdln.option ( ' -v ' , ' --verbose ' , action = ' store_true ' ,
help = ' print extra information ' )
2009-08-20 21:28:05 +02:00
@cmdln.option ( ' -l ' , ' --long ' , action = ' store_true ' , dest = ' verbose ' ,
help = ' print extra information ' )
2007-04-25 01:00:12 +02:00
def do_list ( self , subcmd , opts , * args ) :
2010-01-12 13:31:25 +01:00
""" $ {cmd_name} : List sources or binaries on the server
2007-08-16 20:15:08 +02:00
2010-01-12 13:31:25 +01:00
Examples for listing sources :
2009-10-16 21:56:33 +02:00
ls # list all projects
2010-01-12 13:31:25 +01:00
ls PROJECT # list packages in a project
ls PROJECT PACKAGE # list source files of package of a project
ls PROJECT PACKAGE < file > # list <file> if this file exists
ls - v PROJECT PACKAGE # verbosely list source files of package
ls - l PROJECT PACKAGE # verbosely list source files of package
ll PROJECT PACKAGE # verbosely list source files of package
LL PROJECT PACKAGE # verbosely list source files of expanded link
2007-06-26 15:17:38 +02:00
With - - verbose , the following fields will be shown for each item :
MD5 hash of file
Revision number of the last commit
Size ( in bytes )
Date and time of the last commit
2007-04-25 01:00:12 +02:00
2010-01-12 13:31:25 +01:00
Examples for listing binaries :
ls - b PROJECT # list all binaries of a project
ls - b PROJECT - a ARCH # list ARCH binaries of a project
ls - b PROJECT - r REPO # list binaries in REPO
ls - b PROJECT PACKAGE REPO ARCH
Usage :
$ { cmd_name } [ PROJECT [ PACKAGE ] ]
$ { cmd_name } - b [ PROJECT [ PACKAGE [ REPO [ ARCH ] ] ] ]
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2009-11-17 14:39:46 +01:00
apiurl = conf . config [ ' apiurl ' ]
2007-06-26 15:17:38 +02:00
args = slash_split ( args )
2009-08-21 21:39:12 +02:00
if subcmd == ' ll ' :
opts . verbose = True
if subcmd == ' lL ' or subcmd == ' LL ' :
opts . verbose = True
opts . expand = True
2007-06-26 15:17:38 +02:00
2009-11-17 14:39:46 +01:00
project = None
package = None
2010-01-12 13:31:25 +01:00
fname = None
if len ( args ) > 0 :
2007-04-25 01:00:12 +02:00
project = args [ 0 ]
2010-01-12 13:31:25 +01:00
if len ( args ) > 1 :
2007-04-25 01:00:12 +02:00
package = args [ 1 ]
2010-01-12 13:31:25 +01:00
if len ( args ) > 2 :
if opts . binaries :
if opts . repo :
if opts . repo != args [ 2 ] :
raise oscerr . WrongArgs ( " conflicting repos specified ( ' %s ' vs ' %s ' ) " % ( opts . repo , args [ 2 ] ) )
else :
opts . repo = args [ 2 ]
else :
2008-11-20 13:56:16 +01:00
fname = args [ 2 ]
2010-01-12 13:31:25 +01:00
if len ( args ) > 3 :
if not opts . binaries :
raise oscerr . WrongArgs ( ' Too many arguments ' )
if opts . arch :
if opts . arch != args [ 3 ] :
raise oscerr . WrongArgs ( " conflicting archs specified ( ' %s ' vs ' %s ' ) " % ( opts . arch , args [ 3 ] ) )
else :
opts . arch = args [ 3 ]
2007-08-16 20:15:08 +02:00
2009-03-31 00:28:26 +02:00
if opts . binaries and opts . expand :
raise oscerr . WrongOptions ( ' Sorry, --binaries and --expand are mutual exclusive. ' )
2007-08-16 20:15:08 +02:00
# list binaries
if opts . binaries :
2009-11-17 14:39:46 +01:00
# ls -b toplevel doesn't make sense, so use info from
# current dir if available
if len ( args ) == 0 :
dir = os . getcwd ( )
if is_project_dir ( dir ) :
project = store_read_project ( dir )
apiurl = store_read_apiurl ( dir )
elif is_package_dir ( dir ) :
project = store_read_project ( dir )
package = store_read_package ( dir )
apiurl = store_read_apiurl ( dir )
if not project :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' There are no binaries to list above project level. ' )
2009-04-09 10:21:12 +02:00
if opts . revision :
raise oscerr . WrongOptions ( ' Sorry, the --revision option is not supported for binaries. ' )
2007-08-16 20:15:08 +02:00
2009-11-17 14:39:46 +01:00
repos = [ ]
if opts . repo and opts . arch :
repos . append ( Repo ( opts . repo , opts . arch ) )
elif opts . repo and not opts . arch :
2010-04-09 03:37:04 +02:00
repos = [ repo for repo in get_repos_of_project ( apiurl , project ) if repo . name == opts . repo ]
2009-11-17 14:39:46 +01:00
elif opts . arch and not opts . repo :
2010-04-09 03:37:04 +02:00
repos = [ repo for repo in get_repos_of_project ( apiurl , project ) if repo . arch == opts . arch ]
2009-11-17 14:39:46 +01:00
else :
repos = get_repos_of_project ( apiurl , project )
2009-11-04 15:31:20 +01:00
2009-11-17 14:39:46 +01:00
results = [ ]
for repo in repos :
results . append ( ( repo , get_binarylist ( apiurl , project , repo . name , repo . arch , package = package , verbose = opts . verbose ) ) )
2007-08-16 20:15:08 +02:00
2009-11-17 14:39:46 +01:00
for result in results :
indent = ' '
if len ( results ) > 1 :
print ' %s / %s ' % ( result [ 0 ] . name , result [ 0 ] . arch )
indent = ' '
2009-11-04 15:31:20 +01:00
2009-11-17 14:39:46 +01:00
if opts . verbose :
for f in result [ 1 ] :
print " %9d %s %-40s " % ( f . size , shorttime ( f . mtime ) , f . name )
else :
for f in result [ 1 ] :
print indent + f
2007-08-16 20:15:08 +02:00
# list sources
elif not opts . binaries :
if not args :
print ' \n ' . join ( meta_get_project_list ( conf . config [ ' apiurl ' ] ) )
elif len ( args ) == 1 :
if opts . verbose :
2009-08-20 21:28:05 +02:00
if self . options . verbose :
print >> sys . stderr , ' Sorry, the --verbose option is not implemented for projects. '
2009-03-31 00:28:26 +02:00
if opts . expand :
raise oscerr . WrongOptions ( ' Sorry, the --expand option is not implemented for projects. ' )
2007-08-16 20:15:08 +02:00
print ' \n ' . join ( meta_get_packagelist ( conf . config [ ' apiurl ' ] , project ) )
2008-11-20 13:56:16 +01:00
elif len ( args ) == 2 or len ( args ) == 3 :
2010-03-08 23:52:51 +01:00
link_seen = False
print_not_found = True
2010-04-09 01:22:26 +02:00
rev = opts . revision
2010-03-08 23:52:51 +01:00
for i in [ 1 , 2 ] :
l = meta_get_filelist ( conf . config [ ' apiurl ' ] ,
2009-05-18 16:50:43 +02:00
project ,
2007-08-16 20:15:08 +02:00
package ,
2009-03-31 00:28:26 +02:00
verbose = opts . verbose ,
2009-04-09 10:21:12 +02:00
expand = opts . expand ,
2010-04-09 01:22:26 +02:00
revision = rev )
2010-04-06 10:57:49 +02:00
link_seen = ' _link ' in l
2010-03-08 23:52:51 +01:00
if opts . verbose :
out = [ ' %s %7s %9d %s %s ' % ( i . md5 , i . rev , i . size , shorttime ( i . mtime ) , i . name ) \
2008-11-20 13:56:16 +01:00
for i in l if not fname or fname == i . name ]
2010-03-08 23:52:51 +01:00
if len ( out ) > 0 :
print_not_found = False
print ' \n ' . join ( out )
2010-04-09 03:37:04 +02:00
elif fname :
if fname in l :
print fname
print_not_found = False
2008-11-20 13:56:16 +01:00
else :
2010-04-09 03:37:04 +02:00
print ' \n ' . join ( l )
2010-04-06 11:04:48 +02:00
if opts . expand or opts . unexpand or not link_seen : break
2010-03-08 23:52:51 +01:00
m = show_files_meta ( conf . config [ ' apiurl ' ] , project , package )
2010-04-09 01:22:26 +02:00
li = Linkinfo ( )
li . read ( ET . fromstring ( ' ' . join ( m ) ) . find ( ' linkinfo ' ) )
if li . haserror ( ) :
raise oscerr . LinkExpandError ( project , package , li . error )
project , package , rev = li . project , li . package , li . rev
if rev :
print ' # -> %s %s ( %s ) ' % ( project , package , rev )
else :
print ' # -> %s %s (latest) ' % ( project , package )
2010-03-08 23:52:51 +01:00
opts . expand = True
if fname and print_not_found :
print ' file \' %s \' does not exist ' % fname
2007-04-25 01:00:12 +02:00
2009-11-10 10:56:34 +01:00
@cmdln.option ( ' -f ' , ' --force ' , action = ' store_true ' ,
help = ' force generation of new patchinfo file ' )
@cmdln.option ( ' --force-update ' , action = ' store_true ' ,
help = ' drops away collected packages from an already built patch and let it collect again ' )
def do_patchinfo ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Generate and edit a patchinfo file.
A patchinfo file describes the packages for an update and the kind of
problem it solves .
Examples :
osc patchinfo
osc patchinfo PATCH_NAME
$ { cmd_option_list }
"""
project_dir = localdir = os . getcwd ( )
if is_project_dir ( localdir ) :
2009-12-21 23:47:25 +01:00
project = store_read_project ( localdir )
apiurl = store_read_apiurl ( localdir )
2009-11-10 10:56:34 +01:00
else :
sys . exit ( ' This command must be called in a checked out project. ' )
2009-11-13 09:58:37 +01:00
patchinfo = None
2009-11-10 10:56:34 +01:00
for p in meta_get_packagelist ( apiurl , project ) :
if p . startswith ( " _patchinfo: " ) :
patchinfo = p
2010-02-28 02:30:13 +01:00
2009-11-10 10:56:34 +01:00
if opts . force or not patchinfo :
print " Creating initial patchinfo... "
query = ' cmd=createpatchinfo '
2009-11-13 09:58:37 +01:00
if args and args [ 0 ] :
2010-02-27 20:11:15 +01:00
query + = " &name= " + args [ 0 ]
2009-11-10 10:56:34 +01:00
url = makeurl ( apiurl , [ ' source ' , project ] , query = query )
f = http_POST ( url )
2010-02-24 20:02:52 +01:00
for p in meta_get_packagelist ( apiurl , project ) :
if p . startswith ( " _patchinfo: " ) :
patchinfo = p
2009-11-10 10:56:34 +01:00
if not os . path . exists ( project_dir + " / " + patchinfo ) :
checkout_package ( apiurl , project , patchinfo , prj_dir = project_dir )
if sys . platform [ : 3 ] != ' win ' :
editor = os . getenv ( ' EDITOR ' , default = ' vim ' )
else :
editor = os . getenv ( ' EDITOR ' , default = ' notepad ' )
subprocess . call ( ' %s %s ' % ( editor , project_dir + " / " + patchinfo + " /_patchinfo " ) , shell = True )
2009-10-30 10:40:46 +01:00
@cmdln.option ( ' -a ' , ' --attribute ' , metavar = ' ATTRIBUTE ' ,
help = ' affect only a given attribute ' )
2009-10-30 11:18:44 +01:00
@cmdln.option ( ' --attribute-defaults ' , action = ' store_true ' ,
help = ' include defined attribute defaults ' )
@cmdln.option ( ' --attribute-project ' , action = ' store_true ' ,
help = ' include project values, if missing in packages ' )
2007-07-13 18:01:02 +02:00
@cmdln.option ( ' -F ' , ' --file ' , metavar = ' FILE ' ,
2007-07-16 12:58:11 +02:00
help = ' read metadata from FILE, instead of opening an editor. '
' \' - \' denotes standard input. ' )
2007-07-16 18:20:09 +02:00
@cmdln.option ( ' -e ' , ' --edit ' , action = ' store_true ' ,
help = ' edit metadata ' )
2009-10-30 10:40:46 +01:00
@cmdln.option ( ' -c ' , ' --create ' , action = ' store_true ' ,
help = ' create attribute without values ' )
@cmdln.option ( ' -s ' , ' --set ' , metavar = ' ATTRIBUTE_VALUES ' ,
help = ' set attribute values ' )
2007-07-19 14:23:42 +02:00
@cmdln.option ( ' --delete ' , action = ' store_true ' ,
2009-10-30 10:40:46 +01:00
help = ' delete a pattern or attribute ' )
2007-04-25 01:00:12 +02:00
def do_meta ( self , subcmd , opts , * args ) :
2007-07-13 18:01:02 +02:00
""" $ {cmd_name} : Show meta information, or edit it
2006-09-15 12:53:44 +02:00
2007-07-19 12:08:42 +02:00
Show or edit build service metadata of type < prj | pkg | prjconf | user | pattern > .
2007-07-16 12:58:11 +02:00
This command displays metadata on buildservice objects like projects ,
packages , or users . The type of metadata is specified by the word after
" meta " , like e . g . " meta prj " .
2007-07-16 15:40:58 +02:00
prj denotes metadata of a buildservice project .
prjconf denotes the ( build ) configuration of a project .
pkg denotes metadata of a buildservice package .
user denotes the metadata of a user .
2007-07-19 12:14:10 +02:00
pattern denotes installation patterns defined for a project .
To list patterns , use ' osc meta pattern PRJ ' . An additional argument
will be the pattern file to view or edit .
2007-07-16 15:40:58 +02:00
2007-07-16 12:58:11 +02:00
With the - - edit switch , the metadata can be edited . Per default , osc
opens the program specified by the environmental variable EDITOR with a
temporary file . Alternatively , content to be saved can be supplied via
2007-07-16 18:20:09 +02:00
the - - file switch . If the argument is ' - ' , input is taken from stdin :
2009-03-02 15:03:06 +01:00
osc meta prjconf home : user | sed . . . | osc meta prjconf home : user - F -
2007-07-16 12:58:11 +02:00
2009-05-27 14:09:50 +02:00
When trying to edit a non - existing resource , it is created implicitly .
2006-09-15 12:53:44 +02:00
2007-08-09 18:15:13 +02:00
Examples :
osc meta prj PRJ
osc meta pkg PRJ PKG
osc meta pkg PRJ PKG - e
2009-10-30 10:40:46 +01:00
osc meta attribute PRJ [ PKG [ SUBPACKAGE ] ] [ - - attribute ATTRIBUTE ] [ - - create | - - delete | - - set [ value_list ] ]
2007-08-09 18:15:13 +02:00
Usage :
2009-10-30 10:40:46 +01:00
osc meta < prj | pkg | prjconf | user | pattern | attribute > ARGS . . .
osc meta < prj | pkg | prjconf | user | pattern | attribute > - e | - - edit ARGS . . .
osc meta < prj | pkg | prjconf | user | pattern | attribute > - F | - - file ARGS . . .
2007-07-19 14:23:42 +02:00
osc meta pattern - - delete PRJ PATTERN
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2006-05-23 17:27:43 +02:00
2007-07-13 18:01:02 +02:00
args = slash_split ( args )
2006-05-23 17:27:43 +02:00
2007-07-13 18:01:02 +02:00
if not args or args [ 0 ] not in metatypes . keys ( ) :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Unknown meta type. Choose one of %s . ' \
% ' , ' . join ( metatypes ) )
2006-10-12 15:22:56 +02:00
2007-07-13 18:01:02 +02:00
cmd = args [ 0 ]
del args [ 0 ]
2007-06-26 15:17:38 +02:00
2007-07-19 12:08:42 +02:00
if cmd in [ ' pkg ' ] :
min_args , max_args = 2 , 2
elif cmd in [ ' pattern ' ] :
min_args , max_args = 1 , 2
2009-10-30 10:40:46 +01:00
elif cmd in [ ' attribute ' ] :
min_args , max_args = 1 , 3
2007-07-13 18:01:02 +02:00
else :
2007-07-19 12:08:42 +02:00
min_args , max_args = 1 , 1
if len ( args ) < min_args :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Too few arguments. ' )
2007-07-19 12:08:42 +02:00
if len ( args ) > max_args :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Too many arguments. ' )
2006-10-12 15:22:56 +02:00
2007-07-16 18:20:09 +02:00
# specific arguments
2009-10-30 10:40:46 +01:00
attributepath = [ ]
2007-07-13 18:01:02 +02:00
if cmd == ' prj ' :
2007-04-25 01:00:12 +02:00
project = args [ 0 ]
2007-07-13 18:01:02 +02:00
elif cmd == ' pkg ' :
project , package = args [ 0 : 2 ]
2009-10-30 10:40:46 +01:00
elif cmd == ' attribute ' :
project = args [ 0 ]
if len ( args ) > 1 :
2009-12-30 15:10:11 +01:00
package = args [ 1 ]
2009-10-30 10:40:46 +01:00
else :
2009-12-30 15:10:11 +01:00
package = None
if opts . attribute_project :
raise oscerr . WrongOptions ( ' --attribute-project works only when also a package is given ' )
2009-10-30 10:40:46 +01:00
if len ( args ) > 2 :
2009-12-30 15:10:11 +01:00
subpackage = args [ 2 ]
2009-10-30 10:40:46 +01:00
else :
2009-12-30 15:10:11 +01:00
subpackage = None
2009-10-30 10:40:46 +01:00
attributepath . append ( ' source ' )
attributepath . append ( project )
if package :
2009-12-30 15:10:11 +01:00
attributepath . append ( package )
2009-10-30 10:40:46 +01:00
if subpackage :
2009-12-30 15:10:11 +01:00
attributepath . append ( subpackage )
2009-10-30 10:40:46 +01:00
attributepath . append ( ' _attribute ' )
2007-07-13 18:01:02 +02:00
elif cmd == ' prjconf ' :
2007-04-25 01:00:12 +02:00
project = args [ 0 ]
2007-07-13 18:01:02 +02:00
elif cmd == ' user ' :
2007-04-25 01:00:12 +02:00
user = args [ 0 ]
2007-07-19 12:08:42 +02:00
elif cmd == ' pattern ' :
project = args [ 0 ]
if len ( args ) > 1 :
pattern = args [ 1 ]
else :
pattern = None
2007-07-19 13:54:13 +02:00
# enforce pattern argument if needed
if opts . edit or opts . file :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' A pattern file argument is required. ' )
2007-07-16 18:20:09 +02:00
2009-05-18 16:50:43 +02:00
# show
2009-10-30 10:40:46 +01:00
if not opts . edit and not opts . file and not opts . delete and not opts . create and not opts . set :
2007-07-16 18:20:09 +02:00
if cmd == ' prj ' :
sys . stdout . write ( ' ' . join ( show_project_meta ( conf . config [ ' apiurl ' ] , project ) ) )
elif cmd == ' pkg ' :
sys . stdout . write ( ' ' . join ( show_package_meta ( conf . config [ ' apiurl ' ] , project , package ) ) )
2009-10-30 10:40:46 +01:00
elif cmd == ' attribute ' :
2009-10-30 11:18:44 +01:00
sys . stdout . write ( ' ' . join ( show_attribute_meta ( conf . config [ ' apiurl ' ] , project , package , subpackage , opts . attribute , opts . attribute_defaults , opts . attribute_project ) ) )
2007-07-16 18:20:09 +02:00
elif cmd == ' prjconf ' :
sys . stdout . write ( ' ' . join ( show_project_conf ( conf . config [ ' apiurl ' ] , project ) ) )
elif cmd == ' user ' :
2007-07-13 18:01:02 +02:00
r = get_user_meta ( conf . config [ ' apiurl ' ] , user )
if r :
sys . stdout . write ( ' ' . join ( r ) )
2007-07-19 12:08:42 +02:00
elif cmd == ' pattern ' :
if pattern :
r = show_pattern_meta ( conf . config [ ' apiurl ' ] , project , pattern )
if r :
sys . stdout . write ( ' ' . join ( r ) )
else :
r = show_pattern_metalist ( conf . config [ ' apiurl ' ] , project )
if r :
sys . stdout . write ( ' \n ' . join ( r ) + ' \n ' )
2007-07-16 18:20:09 +02:00
# edit
if opts . edit and not opts . file :
if cmd == ' prj ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' prj ' ,
2007-07-16 18:20:09 +02:00
edit = True ,
path_args = quote_plus ( project ) ,
2008-03-07 10:13:30 +01:00
template_args = ( {
' name ' : project ,
' user ' : conf . config [ ' user ' ] } ) )
2007-07-16 18:20:09 +02:00
elif cmd == ' pkg ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' pkg ' ,
2007-07-16 18:20:09 +02:00
edit = True ,
path_args = ( quote_plus ( project ) , quote_plus ( package ) ) ,
2008-03-07 10:13:30 +01:00
template_args = ( {
' name ' : package ,
' user ' : conf . config [ ' user ' ] } ) )
2007-07-16 18:20:09 +02:00
elif cmd == ' prjconf ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' prjconf ' ,
2007-07-16 18:20:09 +02:00
edit = True ,
path_args = quote_plus ( project ) ,
template_args = None )
elif cmd == ' user ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' user ' ,
2007-07-16 18:20:09 +02:00
edit = True ,
path_args = ( quote_plus ( user ) ) ,
2008-03-07 10:13:30 +01:00
template_args = ( { ' user ' : user } ) )
2007-07-19 12:08:42 +02:00
elif cmd == ' pattern ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' pattern ' ,
2007-07-19 12:08:42 +02:00
edit = True ,
path_args = ( project , pattern ) ,
template_args = None )
2007-07-16 18:20:09 +02:00
2009-10-30 10:40:46 +01:00
# create attribute entry
2009-12-30 15:10:11 +01:00
if ( opts . create or opts . set ) and cmd == ' attribute ' :
if not opts . attribute :
raise oscerr . WrongOptions ( ' no attribute given to create ' )
values = ' '
if opts . set :
opts . set = opts . set . replace ( ' & ' , ' & ' ) . replace ( ' < ' , ' < ' ) . replace ( ' > ' , ' > ' )
for i in opts . set . split ( ' , ' ) :
values + = ' <value> %s </value> ' % i
2010-01-21 10:31:53 +01:00
aname = opts . attribute . split ( " : " )
d = ' <attributes><attribute namespace= \' %s \' name= \' %s \' > %s </attribute></attributes> ' % ( aname [ 0 ] , aname [ 1 ] , values )
2009-12-30 15:10:11 +01:00
url = makeurl ( conf . config [ ' apiurl ' ] , attributepath )
for data in streamfile ( url , http_POST , data = d ) :
sys . stdout . write ( data )
2009-10-30 10:40:46 +01:00
2007-07-16 18:20:09 +02:00
# upload file
if opts . file :
if opts . file == ' - ' :
f = sys . stdin . read ( )
2007-07-13 18:01:02 +02:00
else :
2007-07-16 18:20:09 +02:00
try :
f = open ( opts . file ) . read ( )
except :
sys . exit ( ' could not open file \' %s \' . ' % opts . file )
if cmd == ' prj ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' prj ' ,
2007-07-16 18:20:09 +02:00
data = f ,
edit = opts . edit ,
path_args = quote_plus ( project ) )
elif cmd == ' pkg ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' pkg ' ,
2007-07-16 18:20:09 +02:00
data = f ,
edit = opts . edit ,
path_args = ( quote_plus ( project ) , quote_plus ( package ) ) )
elif cmd == ' prjconf ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' prjconf ' ,
2007-07-16 18:20:09 +02:00
data = f ,
edit = opts . edit ,
path_args = quote_plus ( project ) )
elif cmd == ' user ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' user ' ,
2007-07-16 18:20:09 +02:00
data = f ,
edit = opts . edit ,
path_args = ( quote_plus ( user ) ) )
2007-07-19 12:08:42 +02:00
elif cmd == ' pattern ' :
2009-05-18 16:50:43 +02:00
edit_meta ( metatype = ' pattern ' ,
2007-07-19 12:08:42 +02:00
data = f ,
edit = opts . edit ,
path_args = ( project , pattern ) )
2007-07-16 18:20:09 +02:00
2007-07-13 18:01:02 +02:00
2007-07-19 14:23:42 +02:00
# delete
if opts . delete :
path = metatypes [ cmd ] [ ' path ' ]
if cmd == ' pattern ' :
path = path % ( project , pattern )
u = makeurl ( conf . config [ ' apiurl ' ] , [ path ] )
2008-04-10 23:04:17 +02:00
http_DELETE ( u )
2009-10-30 10:40:46 +01:00
elif cmd == ' attribute ' :
if not opts . attribute :
2009-12-30 15:10:11 +01:00
raise oscerr . WrongOptions ( ' no attribute given to create ' )
2009-10-30 10:40:46 +01:00
attributepath . append ( opts . attribute )
u = makeurl ( conf . config [ ' apiurl ' ] , attributepath )
2009-12-30 15:10:11 +01:00
for data in streamfile ( u , http_DELETE ) :
sys . stdout . write ( data )
2007-07-19 14:23:42 +02:00
else :
2009-12-30 15:10:11 +01:00
raise oscerr . WrongOptions ( ' The --delete switch is only for pattern metadata or attributes. ' )
2007-07-19 14:23:42 +02:00
2008-03-05 00:41:00 +01:00
@cmdln.option ( ' -m ' , ' --message ' , metavar = ' TEXT ' ,
help = ' specify message TEXT ' )
2008-03-13 00:37:35 +01:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' REV ' ,
help = ' for " create " , specify a certain source revision ID (the md5 sum) ' )
2009-11-17 17:59:17 +01:00
@cmdln.option ( ' -s ' , ' --supersede ' , metavar = ' SUPERSEDE ' ,
help = ' Superseding another request by this one ' )
2008-06-03 17:01:01 +02:00
@cmdln.option ( ' --nodevelproject ' , action = ' store_true ' ,
help = ' do not follow a defined devel project ' \
' (primary project where a package is developed) ' )
2009-09-05 15:46:55 +02:00
@cmdln.option ( ' --cleanup ' , action = ' store_true ' ,
help = ' remove package if submission gets accepted (default for home:<id>:branch projects) ' )
@cmdln.option ( ' --no-cleanup ' , action = ' store_true ' ,
help = ' never remove source package on accept, but update its content ' )
@cmdln.option ( ' --no-update ' , action = ' store_true ' ,
help = ' never touch source package on accept (will break source links) ' )
2009-08-28 09:33:16 +02:00
@cmdln.option ( ' -d ' , ' --diff ' , action = ' store_true ' ,
help = ' show diff only instead of creating the actual request ' )
2009-11-13 09:58:37 +01:00
@cmdln.option ( ' --yes ' , action = ' store_true ' ,
help = ' proceed without asking. ' )
2008-07-09 22:38:49 +02:00
@cmdln.alias ( " sr " )
2009-06-02 16:57:42 +02:00
@cmdln.alias ( " submitreq " )
2009-08-20 21:28:05 +02:00
@cmdln.alias ( " submitpac " )
2009-06-02 16:57:42 +02:00
def do_submitrequest ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Create request to submit source into another Project
2008-03-05 00:41:00 +01:00
2008-06-06 14:04:34 +02:00
[ See http : / / en . opensuse . org / Build_Service / Collaboration for information
on this topic . ]
2009-06-02 16:57:42 +02:00
See the " request " command for showing and modifing existing requests .
2009-06-02 15:14:46 +02:00
2009-06-02 16:57:42 +02:00
usage :
2009-07-13 11:36:19 +02:00
osc submitreq [ OPTIONS ]
osc submitreq [ OPTIONS ] DESTPRJ [ DESTPKG ]
osc submitreq [ OPTIONS ] SOURCEPRJ SOURCEPKG DESTPRJ [ DESTPKG ]
2009-06-02 16:57:42 +02:00
$ { cmd_option_list }
2009-06-02 15:14:46 +02:00
"""
2009-12-19 14:44:51 +01:00
src_update = conf . config [ ' submitrequest_on_accept_action ' ] or None
2009-09-05 15:46:55 +02:00
# we should check here for home:<id>:branch and default to update, but that would require OBS 1.7 server
if opts . cleanup :
2009-10-20 16:30:15 +02:00
src_update = " cleanup "
2009-09-05 15:46:55 +02:00
elif opts . no_cleanup :
2009-10-20 16:30:15 +02:00
src_update = " update "
2009-09-05 15:46:55 +02:00
elif opts . no_update :
2009-10-20 16:30:15 +02:00
src_update = " noupdate "
2009-09-05 15:46:55 +02:00
2009-06-02 16:57:42 +02:00
args = slash_split ( args )
2009-06-02 15:14:46 +02:00
2009-06-05 07:46:20 +02:00
# remove this block later again
oldcmds = [ ' create ' , ' list ' , ' log ' , ' show ' , ' decline ' , ' accept ' , ' delete ' , ' revoke ' ]
if args and args [ 0 ] in oldcmds :
2009-09-03 19:28:27 +02:00
print " ************************************************************************ "
print " * WARNING: It looks that you are using this command with a * "
2010-02-02 13:34:12 +01:00
print " * deprecated syntax. * "
print " * Please run \" osc sr --help \" and \" osc rq --help \" * "
2009-09-03 19:28:27 +02:00
print " * to see the new syntax. * "
print " ************************************************************************ "
2009-06-05 23:45:29 +02:00
if args [ 0 ] == ' create ' :
args . pop ( 0 )
else :
sys . exit ( 1 )
2009-06-05 07:46:20 +02:00
2009-06-02 16:57:42 +02:00
if len ( args ) > 4 :
2009-06-02 15:14:46 +02:00
raise oscerr . WrongArgs ( ' Too many arguments. ' )
2009-11-13 09:58:37 +01:00
if len ( args ) > 0 and len ( args ) < = 2 and is_project_dir ( os . getcwd ( ) ) :
2009-12-25 00:39:13 +01:00
sys . exit ( ' osc submitrequest from project directory is only working without target specs and for source linked files \n ' )
2009-11-13 09:58:37 +01:00
2009-11-16 10:42:58 +01:00
apiurl = conf . config [ ' apiurl ' ]
2009-11-13 09:58:37 +01:00
if len ( args ) == 0 and is_project_dir ( os . getcwd ( ) ) :
import cgi
# submit requests for multiple packages are currently handled via multiple requests
# They could be also one request with multiple actions, but that avoids to accepts parts of it.
2009-12-21 23:47:25 +01:00
project = store_read_project ( os . curdir )
apiurl = store_read_apiurl ( os . curdir )
2009-11-13 09:58:37 +01:00
sr_ids = [ ]
pi = [ ]
pac = [ ]
targetprojects = [ ]
# loop via all packages for checking their state
2009-12-21 23:47:25 +01:00
for p in meta_get_packagelist ( apiurl , project ) :
2009-11-13 09:58:37 +01:00
if p . startswith ( " _patchinfo: " ) :
2010-02-24 20:02:52 +01:00
pi . append ( p )
2009-11-13 09:58:37 +01:00
else :
2010-03-05 12:54:12 +01:00
# get _link info from server, that knows about the local state ...
2010-02-24 20:02:52 +01:00
u = makeurl ( apiurl , [ ' source ' , project , p ] )
f = http_GET ( u )
root = ET . parse ( f ) . getroot ( )
linkinfo = root . find ( ' linkinfo ' )
if linkinfo == None :
print " Package " , p , " is not a source link. "
sys . exit ( " This is currently not supported. " )
if linkinfo . get ( ' error ' ) :
print " Package " , p , " is a broken source link. "
sys . exit ( " Please fix this first " )
t = linkinfo . get ( ' project ' )
if t :
if len ( root . findall ( ' entry ' ) ) > 1 : # This is not really correct, but should work mostly
# Real fix is to ask the api if sources are modificated
# but there is no such call yet.
targetprojects . append ( t )
pac . append ( p )
print " Submitting package " , p
else :
print " Skipping package " , p
else :
2010-03-05 12:54:12 +01:00
print " Skipping package " , p , " since it is a source link pointing inside the project. "
2009-11-13 09:58:37 +01:00
if not opts . yes :
if pi :
2010-02-24 20:02:52 +01:00
print " Submitting patchinfo " , ' , ' . join ( pi ) , " to " , ' , ' . join ( targetprojects )
2009-11-13 09:58:37 +01:00
print " \n Everything fine? Can we create the requests ? [y/n] "
if sys . stdin . read ( 1 ) != " y " :
2010-02-24 20:02:52 +01:00
sys . exit ( " Aborted... " )
2009-11-13 09:58:37 +01:00
# loop via all packages to do the action
for p in pac :
2009-12-21 23:47:25 +01:00
result = create_submit_request ( apiurl , project , p )
2009-11-13 09:58:37 +01:00
if not result :
2010-02-27 20:11:15 +01:00
# sys.exit(result)
sys . exit ( " submit request creation failed " )
2009-11-13 09:58:37 +01:00
sr_ids . append ( result )
# create submit requests for all found patchinfos
actionxml = " "
options_block = " "
if src_update :
options_block = """ <options><sourceupdate> %s </sourceupdate></options> """ % ( src_update )
for p in pi :
for t in targetprojects :
s = """ <action type= " submit " > <source project= " %s " package= " %s " /> <target project= " %s " package= " %s " /> %s </action> """ % \
2009-12-21 23:47:25 +01:00
( project , p , t , p , options_block )
2009-11-13 09:58:37 +01:00
actionxml + = s
if actionxml != " " :
xml = """ <request> %s <state name= " new " /> <description> %s </description> </request> """ % \
( actionxml , cgi . escape ( opts . message or " " ) )
u = makeurl ( apiurl , [ ' request ' ] , query = ' cmd=create ' )
f = http_POST ( u , data = xml )
2010-02-28 02:30:13 +01:00
2009-11-13 09:58:37 +01:00
root = ET . parse ( f ) . getroot ( )
sr_ids . append ( root . get ( ' id ' ) )
print " Requests created: " ,
for i in sr_ids :
2010-02-27 20:11:15 +01:00
print i ,
2009-11-13 09:58:37 +01:00
sys . exit ( ' Successfull finished ' )
elif len ( args ) < = 2 :
2009-06-02 16:57:42 +02:00
# try using the working copy at hand
p = findpacs ( os . curdir ) [ 0 ]
src_project = p . prjname
src_package = p . name
2009-12-15 17:38:09 +01:00
apiurl = p . apiurl
2009-06-02 16:57:42 +02:00
if len ( args ) == 0 and p . islink ( ) :
dst_project = p . linkinfo . project
dst_package = p . linkinfo . package
elif len ( args ) > 0 :
dst_project = args [ 0 ]
if len ( args ) == 2 :
dst_package = args [ 1 ]
2009-06-02 15:14:46 +02:00
else :
dst_package = src_package
else :
2009-06-02 16:57:42 +02:00
sys . exit ( ' Package \' %s \' is not a source link, so I cannot guess the submit target. \n '
' Please provide it the target via commandline arguments. ' % p . name )
modified = [ i for i in p . filenamelist if p . status ( i ) != ' ' and p . status ( i ) != ' ? ' ]
if len ( modified ) > 0 :
print ' Your working copy has local modifications. '
repl = raw_input ( ' Proceed without committing the local changes? (y|N) ' )
if repl != ' y ' :
sys . exit ( 1 )
elif len ( args ) > = 3 :
# get the arguments from the commandline
src_project , src_package , dst_project = args [ 0 : 3 ]
if len ( args ) == 4 :
dst_package = args [ 3 ]
else :
dst_package = src_package
else :
raise oscerr . WrongArgs ( ' Incorrect number of arguments. \n \n ' \
+ self . get_cmd_help ( ' request ' ) )
if not opts . nodevelproject :
devloc = None
try :
devloc = show_develproject ( apiurl , dst_project , dst_package )
except urllib2 . HTTPError :
print >> sys . stderr , """ \
2009-06-02 15:14:46 +02:00
Warning : failed to fetch meta data for ' %s ' package ' %s ' ( new package ? ) """ \
2009-06-02 16:57:42 +02:00
% ( dst_project , dst_package )
pass
2009-06-02 15:14:46 +02:00
2009-10-20 16:30:15 +02:00
if devloc and \
dst_project != devloc and \
src_project != devloc :
print """ \
2010-02-02 14:38:50 +01:00
A different project , % s , is defined as the place where development
2009-06-02 15:14:46 +02:00
of the package % s primarily takes place .
Please submit there instead , or use - - nodevelproject to force direct submission . """ \
2009-06-02 16:57:42 +02:00
% ( devloc , dst_package )
2010-02-02 14:38:50 +01:00
if not opts . diff :
sys . exit ( 1 )
2010-02-02 14:38:35 +01:00
rdiff = None
if opts . diff or not opts . message :
try :
rdiff = ' old: %s / %s \n new: %s / %s ' % ( dst_project , dst_package , src_project , src_package )
rdiff + = server_diff ( apiurl ,
dst_project , dst_package , opts . revision ,
src_project , src_package , None , True )
except :
rdiff = ' '
2009-08-28 09:33:16 +02:00
if opts . diff :
print rdiff
else :
2009-09-24 16:14:11 +02:00
reqs = get_request_list ( apiurl , dst_project , dst_package , req_type = ' submit ' )
2009-08-28 09:33:16 +02:00
user = conf . get_apiurl_usr ( apiurl )
myreqs = [ i for i in reqs if i . state . who == user ]
repl = ' '
if len ( myreqs ) > 0 :
print ' You already created the following submit request: %s . ' % \
' , ' . join ( [ str ( i . reqid ) for i in myreqs ] )
2010-02-12 14:13:18 +01:00
repl = raw_input ( ' Supersede the old requests? (y/n/c) ' )
2010-02-08 20:16:03 +01:00
if repl . lower ( ) == ' c ' :
print >> sys . stderr , ' Aborting '
sys . exit ( 1 )
2009-08-28 09:33:16 +02:00
if not opts . message :
2010-02-02 14:38:35 +01:00
difflines = [ ]
doappend = False
changes_re = re . compile ( r ' ^--- .* \ .changes ' )
for line in rdiff . split ( ' \n ' ) :
if line . startswith ( ' --- ' ) :
if changes_re . match ( line ) :
doappend = True
else :
doappend = False
if doappend :
difflines . append ( line )
opts . message = edit_message ( footer = rdiff , template = ' \n ' . join ( parse_diff_for_commit_message ( ' \n ' . join ( difflines ) ) ) )
2009-08-28 09:33:16 +02:00
result = create_submit_request ( apiurl ,
src_project , src_package ,
dst_project , dst_package ,
2009-09-10 10:48:44 +02:00
opts . message , orev = opts . revision , src_update = src_update )
2010-02-08 20:16:03 +01:00
if repl . lower ( ) == ' y ' :
2009-08-28 09:33:16 +02:00
for req in myreqs :
2009-11-17 17:59:17 +01:00
change_request_state ( apiurl , str ( req . reqid ) , ' superseded ' ,
' superseded by %s ' % result , result )
if opts . supersede :
r = change_request_state ( conf . config [ ' apiurl ' ] ,
opts . supersede , ' superseded ' , opts . message or ' ' , result )
2009-08-28 09:33:16 +02:00
print ' created request id ' , result
2009-06-02 15:14:46 +02:00
2009-06-02 16:57:42 +02:00
@cmdln.option ( ' -m ' , ' --message ' , metavar = ' TEXT ' ,
help = ' specify message TEXT ' )
@cmdln.alias ( " dr " )
@cmdln.alias ( " deletereq " )
def do_deleterequest ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Create request to delete a package or project
2009-06-02 15:14:46 +02:00
2009-06-02 16:57:42 +02:00
usage :
osc deletereq [ - m TEXT ] PROJECT [ PACKAGE ]
$ { cmd_option_list }
"""
2009-06-02 15:14:46 +02:00
2009-06-02 16:57:42 +02:00
args = slash_split ( args )
2009-06-02 15:14:46 +02:00
2009-08-07 11:25:34 +02:00
if len ( args ) < 1 :
raise oscerr . WrongArgs ( ' Please specify at least a project. ' )
2009-06-02 16:57:42 +02:00
if len ( args ) > 2 :
raise oscerr . WrongArgs ( ' Too many arguments. ' )
2009-06-02 15:14:46 +02:00
2009-06-02 16:57:42 +02:00
apiurl = conf . config [ ' apiurl ' ]
2009-06-23 12:06:31 +02:00
2009-06-02 16:57:42 +02:00
project = args [ 0 ]
package = None
if len ( args ) > 1 :
2009-10-20 16:30:15 +02:00
package = args [ 1 ]
2009-08-19 13:28:16 +02:00
if not opts . message :
opts . message = edit_message ( )
2009-06-02 16:57:42 +02:00
result = create_delete_request ( apiurl , project , package , opts . message )
print result
2009-06-02 15:14:46 +02:00
2009-06-02 16:57:42 +02:00
@cmdln.option ( ' -m ' , ' --message ' , metavar = ' TEXT ' ,
help = ' specify message TEXT ' )
@cmdln.alias ( " cr " )
@cmdln.alias ( " changedevelreq " )
def do_changedevelrequest ( self , subcmd , opts , * args ) :
2009-07-23 10:01:31 +02:00
""" $ {cmd_name} : Create request to change the devel package definition.
2009-06-02 15:14:46 +02:00
2009-06-02 16:57:42 +02:00
[ See http : / / en . opensuse . org / Build_Service / Collaboration for information
on this topic . ]
See the " request " command for showing and modifing existing requests .
osc changedevelrequest PROJECT PACKAGE DEVEL_PROJECT [ DEVEL_PACKAGE ]
"""
if len ( args ) > 4 :
raise oscerr . WrongArgs ( ' Too many arguments. ' )
2010-02-11 11:26:03 +01:00
if len ( args ) == 0 and is_package_dir ( ' . ' ) and len ( conf . config [ ' getpac_default_project ' ] ) :
wd = os . curdir
2010-02-24 11:41:59 +01:00
devel_project = store_read_project ( wd )
devel_package = package = store_read_package ( wd )
2010-02-11 11:26:03 +01:00
apiurl = store_read_apiurl ( wd )
2010-02-24 11:41:59 +01:00
project = conf . config [ ' getpac_default_project ' ]
2010-02-11 11:26:03 +01:00
else :
if len ( args ) < 3 :
raise oscerr . WrongArgs ( ' Too few arguments. ' )
2009-06-02 16:57:42 +02:00
2010-02-11 11:26:03 +01:00
apiurl = conf . config [ ' apiurl ' ]
devel_project = args [ 2 ]
project = args [ 0 ]
package = args [ 1 ]
devel_package = package
if len ( args ) > 3 :
devel_package = args [ 3 ]
2009-08-19 13:28:16 +02:00
if not opts . message :
2010-02-24 11:41:59 +01:00
import textwrap
footer = textwrap . TextWrapper ( width = 66 ) . fill (
' please explain why you like to change the devel project of %s / %s to %s / %s '
% ( project , package , devel_project , devel_package ) )
opts . message = edit_message ( footer )
2009-08-19 13:28:16 +02:00
2009-06-02 16:57:42 +02:00
result = create_change_devel_request ( apiurl ,
devel_project , devel_package ,
project , package ,
opts . message )
print result
2009-06-02 15:14:46 +02:00
@cmdln.option ( ' -d ' , ' --diff ' , action = ' store_true ' ,
help = ' generate a diff ' )
@cmdln.option ( ' -u ' , ' --unified ' , action = ' store_true ' ,
help = ' output the diff in the unified diff format ' )
@cmdln.option ( ' -m ' , ' --message ' , metavar = ' TEXT ' ,
help = ' specify message TEXT ' )
2009-11-20 17:06:05 +01:00
@cmdln.option ( ' -t ' , ' --type ' , metavar = ' TYPE ' ,
2009-06-19 15:10:33 +02:00
help = ' limit to requests which contain a given action type (submit/delete/change_devel) ' )
2009-08-19 15:00:22 +02:00
@cmdln.option ( ' -a ' , ' --all ' , action = ' store_true ' ,
2009-08-20 21:28:05 +02:00
help = ' all states. Same as \' -s all \' ' )
@cmdln.option ( ' -s ' , ' --state ' , default = ' ' , # default is 'all' if no args given, 'new' otherwise
2009-09-01 17:44:57 +02:00
help = ' only list requests in one of the comma separated given states (new/accepted/revoked/declined) or " all " [default=new, or all, if no args given] ' )
2009-08-21 02:42:51 +02:00
@cmdln.option ( ' -D ' , ' --days ' , metavar = ' DAYS ' ,
2009-09-28 21:50:57 +02:00
help = ' only list requests in state " new " or changed in the last DAYS. [default= %(request_list_days)s ] ' )
2009-08-20 21:28:05 +02:00
@cmdln.option ( ' -U ' , ' --user ' , metavar = ' USER ' ,
help = ' same as -M, but for the specified USER ' )
2009-06-02 15:14:46 +02:00
@cmdln.option ( ' -b ' , ' --brief ' , action = ' store_true ' , default = False ,
help = ' print output in list view as list subcommand ' )
@cmdln.option ( ' -M ' , ' --mine ' , action = ' store_true ' ,
help = ' only show requests created by yourself ' )
2009-09-28 21:50:57 +02:00
@cmdln.option ( ' -B ' , ' --bugowner ' , action = ' store_true ' ,
help = ' also show requests about packages where I am bugowner ' )
2010-02-11 01:47:47 +01:00
@cmdln.option ( ' -i ' , ' --interactive ' , action = ' store_true ' ,
help = ' interactive review of request ' )
2010-03-23 16:21:09 +01:00
@cmdln.option ( ' --non-interactive ' , action = ' store_true ' ,
help = ' non-interactive review of request ' )
2010-02-25 22:56:21 +01:00
@cmdln.option ( ' --exclude-target-project ' , action = ' append ' ,
help = ' exclude target project from request list ' )
2010-03-13 21:06:18 +01:00
@cmdln.option ( ' --involved-projects ' , action = ' store_true ' ,
2010-03-15 13:34:38 +01:00
help = ' show all requests for project/packages where USER is involved ' )
2009-06-02 15:14:46 +02:00
@cmdln.alias ( " rq " )
2009-11-17 17:59:17 +01:00
@cmdln.alias ( " review " )
2009-06-02 15:14:46 +02:00
def do_request ( self , subcmd , opts , * args ) :
2009-06-23 12:06:31 +02:00
""" $ {cmd_name} : Show and modify requests
2009-06-02 15:14:46 +02:00
[ See http : / / en . opensuse . org / Build_Service / Collaboration for information
on this topic . ]
2009-06-02 16:57:42 +02:00
This command shows and modifies existing requests . To create new requests
you need to call one of the following :
osc submitrequest
osc deleterequest
osc changedevelrequest
2009-09-03 19:28:27 +02:00
To send low level requests to the buildservice API , use :
osc api
2009-06-02 16:57:42 +02:00
This command has the following sub commands :
2008-03-05 00:41:00 +01:00
2009-08-20 21:28:05 +02:00
" list " lists open requests attached to a project or package or person .
Uses the project / package of the current directory if none of
- M , - U USER , project / package are given .
2008-03-05 00:41:00 +01:00
2008-08-19 16:18:05 +02:00
" log " will show the history of the given ID
2008-03-06 11:25:45 +01:00
" show " will show the request itself , and generate a diff for review , if
2010-01-02 12:25:37 +01:00
used with the - - diff option . The keyword show can be omitted if the ID is numeric .
2008-03-05 00:41:00 +01:00
2008-03-13 00:37:35 +01:00
" decline " will change the request state to " declined " and append a
message that you specify with the - - message option .
2008-03-05 00:41:00 +01:00
2009-06-02 16:57:42 +02:00
" wipe " will permanently delete a request .
2008-07-25 11:34:29 +02:00
" revoke " will set the request state to " revoked " and append a
2008-07-09 17:22:18 +02:00
message that you specify with the - - message option .
2008-03-13 00:37:35 +01:00
" accept " will change the request state to " accepted " and will trigger
the actual submit process . That would normally be a server - side copy of
the source package to the target package .
2008-03-05 00:41:00 +01:00
2009-09-16 23:39:45 +02:00
" checkout " will checkout the request ' s source package. This only works for " submit " requests.
2008-03-13 00:37:35 +01:00
usage :
2009-09-28 21:50:57 +02:00
osc request list [ - M ] [ - U USER ] [ - s state ] [ - D DAYS ] [ - t type ] [ - B ] [ PRJ [ PKG ] ]
2009-06-02 15:14:46 +02:00
osc request log ID
2009-09-03 19:28:27 +02:00
osc request [ show ] [ - d ] [ - b ] ID
2009-06-02 15:14:46 +02:00
osc request accept [ - m TEXT ] ID
osc request decline [ - m TEXT ] ID
osc request revoke [ - m TEXT ] ID
2009-06-02 16:57:42 +02:00
osc request wipe ID
2009-09-16 23:39:45 +02:00
osc request checkout / co ID
2009-11-17 17:59:17 +01:00
osc review accept [ - m TEXT ] ID
osc review decline [ - m TEXT ] ID
2008-03-05 00:41:00 +01:00
$ { cmd_option_list }
"""
args = slash_split ( args )
2009-08-21 23:31:45 +02:00
if opts . all and opts . state :
2010-03-23 16:21:09 +01:00
raise oscerr . WrongOptions ( ' Sorry, the options \' --all \' and \' --state \' ' \
' are mutually exclusive. ' )
2009-08-21 23:31:45 +02:00
if opts . mine and opts . user :
2010-03-23 16:21:09 +01:00
raise oscerr . WrongOptions ( ' Sorry, the options \' --user \' and \' --mine \' ' \
' are mutually exclusive. ' )
if opts . interactive and opts . non_interactive :
raise oscerr . WrongOptions ( ' Sorry, the options \' --interactive \' and ' \
' \' --non-interactive \' are mutually exclusive ' )
2009-08-21 23:31:45 +02:00
2009-08-20 21:28:05 +02:00
if not args :
args = [ ' list ' ]
opts . mine = 1
if opts . state == ' ' :
opts . state = ' all '
if opts . state == ' ' :
opts . state = ' new '
2009-10-08 16:40:06 +02:00
cmds = [ ' list ' , ' log ' , ' show ' , ' decline ' , ' accept ' , ' wipe ' , ' revoke ' , ' checkout ' , ' co ' , ' help ' ]
2008-03-05 00:41:00 +01:00
if not args or args [ 0 ] not in cmds :
2009-09-03 19:28:27 +02:00
raise oscerr . WrongArgs ( ' Unknown request action %s . Choose one of %s . ' \
% ( args [ 0 ] , ' , ' . join ( cmds ) ) )
2008-03-05 00:41:00 +01:00
cmd = args [ 0 ]
del args [ 0 ]
2009-10-08 16:40:06 +02:00
if cmd == ' help ' :
return self . do_help ( [ ' help ' , ' request ' ] )
2009-06-02 16:57:42 +02:00
if cmd in [ ' wipe ' ] :
min_args , max_args = 1 , 1
2008-03-05 00:41:00 +01:00
elif cmd in [ ' list ' ] :
2008-06-24 11:37:49 +02:00
min_args , max_args = 0 , 2
2008-03-05 00:41:00 +01:00
else :
min_args , max_args = 1 , 1
if len ( args ) < min_args :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Too few arguments. ' )
2008-03-05 00:41:00 +01:00
if len ( args ) > max_args :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Too many arguments. ' )
2008-03-05 00:41:00 +01:00
2008-06-06 14:04:34 +02:00
apiurl = conf . config [ ' apiurl ' ]
2009-06-02 16:57:42 +02:00
if cmd == ' list ' :
2008-06-24 11:37:49 +02:00
package = None
project = None
if len ( args ) > 0 :
project = args [ 0 ]
2009-08-21 03:26:37 +02:00
elif not opts . mine and not opts . user :
2009-05-15 17:32:15 +02:00
try :
2009-07-24 21:15:51 +02:00
project = store_read_project ( os . curdir )
apiurl = store_read_apiurl ( os . curdir )
2009-05-15 17:32:15 +02:00
package = store_read_package ( os . curdir )
except oscerr . NoWorkingCopy :
pass
2008-06-24 11:37:49 +02:00
2008-03-05 00:41:00 +01:00
if len ( args ) > 1 :
package = args [ 1 ]
2009-09-16 23:39:45 +02:00
elif cmd in [ ' log ' , ' show ' , ' decline ' , ' accept ' , ' wipe ' , ' revoke ' , ' checkout ' , ' co ' ] :
2008-03-05 00:41:00 +01:00
reqid = args [ 0 ]
# list
2009-06-02 16:57:42 +02:00
if cmd == ' list ' :
2009-09-01 17:44:57 +02:00
states = ( ' new ' , ' accepted ' , ' revoked ' , ' declined ' )
2008-08-04 15:20:29 +02:00
state_list = opts . state . split ( ' , ' )
2009-08-20 21:28:05 +02:00
if opts . state == ' all ' :
2009-08-21 23:31:45 +02:00
state_list = [ ' all ' ]
else :
for s in state_list :
if not s in states :
raise oscerr . WrongArgs ( ' Unknown state \' %s \' , try one of %s ' % ( s , ' , ' . join ( states ) ) )
2009-05-17 15:07:55 +02:00
who = ' '
if opts . mine :
who = conf . get_apiurl_usr ( apiurl )
2009-08-20 21:28:05 +02:00
if opts . user :
who = opts . user
2009-08-19 15:00:22 +02:00
if opts . all :
2009-08-21 23:31:45 +02:00
state_list = [ ' all ' ]
2009-05-18 16:50:43 +02:00
2009-09-28 21:50:57 +02:00
## FIXME -B not implemented!
if opts . bugowner :
if ( self . options . debug ) :
print ' list: option --bugowner ignored: not impl. '
2010-03-13 21:06:18 +01:00
if opts . involved_projects :
who = who or conf . get_apiurl_usr ( apiurl )
results = get_user_projpkgs_request_list ( apiurl , who , req_state = state_list ,
req_type = opts . type , exclude_projects = opts . exclude_target_project or [ ] )
else :
results = get_request_list ( apiurl , project , package , who ,
state_list , opts . type , opts . exclude_target_project or [ ] )
2008-06-27 18:36:36 +02:00
results . sort ( reverse = True )
2009-08-20 21:28:05 +02:00
import time
2009-08-21 02:42:51 +02:00
days = opts . days or conf . config [ ' request_list_days ' ]
since = ' '
2009-10-20 16:30:15 +02:00
try :
2009-08-21 02:42:51 +02:00
days = int ( days )
except ValueError :
days = 0
if days > 0 :
since = time . strftime ( ' % Y- % m- %d T % H: % M: % S ' , time . localtime ( time . time ( ) - days * 24 * 3600 ) )
2008-06-27 18:36:36 +02:00
2009-08-20 21:28:05 +02:00
skipped = 0
## bs has received 2009-09-20 a new xquery compare() function
## which allows us to limit the list inside of get_request_list
## That would be much faster for coolo. But counting the remainder
2009-09-28 21:50:57 +02:00
## would not be possible with current xquery implementation.
## Workaround: fetch all, and filter on client side.
2009-09-03 13:25:12 +02:00
## FIXME: date filtering should become implemented on server side
2008-03-05 00:41:00 +01:00
for result in results :
2009-09-28 21:50:57 +02:00
if days == 0 or result . state . when > since or result . state . name == ' new ' :
2009-08-20 21:28:05 +02:00
print result . list_view ( )
else :
skipped + = 1
if skipped :
2009-08-21 02:42:51 +02:00
print " There are %d requests older than %s days. \n " % ( skipped , days )
2008-03-05 00:41:00 +01:00
2008-08-19 16:18:05 +02:00
elif cmd == ' log ' :
2009-06-02 15:14:46 +02:00
for l in get_request_log ( conf . config [ ' apiurl ' ] , reqid ) :
2008-08-19 16:18:05 +02:00
print l
2008-03-05 00:41:00 +01:00
# show
elif cmd == ' show ' :
2009-06-02 15:14:46 +02:00
r = get_request ( conf . config [ ' apiurl ' ] , reqid )
2009-04-22 13:02:32 +02:00
if opts . brief :
print r . list_view ( )
2010-03-23 16:21:09 +01:00
elif ( opts . interactive or conf . config [ ' request_show_interactive ' ] ) and not opts . non_interactive :
2010-02-11 01:47:47 +01:00
return request_interactive_review ( conf . config [ ' apiurl ' ] , r )
2009-04-22 13:02:32 +02:00
else :
print r
2008-03-05 00:41:00 +01:00
# fixme: will inevitably fail if the given target doesn't exist
2010-03-30 00:31:01 +02:00
if opts . diff and r . actions [ 0 ] . type != ' submit ' :
raise oscerr . WrongOptions ( ' \' --diff \' is not possible for request type: \' %s \' ' % r . actions [ 0 ] . type )
elif opts . diff :
2008-03-20 21:11:30 +01:00
try :
2009-01-16 15:43:45 +01:00
print server_diff ( conf . config [ ' apiurl ' ] ,
2009-06-02 15:14:46 +02:00
r . actions [ 0 ] . dst_project , r . actions [ 0 ] . dst_package , None ,
2010-04-10 15:44:15 +02:00
r . actions [ 0 ] . src_project , r . actions [ 0 ] . src_package , r . actions [ 0 ] . src_rev , opts . unified , True )
2008-03-20 21:11:30 +01:00
except urllib2 . HTTPError , e :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
e . osc_msg = ' Diff not possible '
raise
2008-03-05 00:41:00 +01:00
2009-09-16 23:39:45 +02:00
# checkout
elif cmd == ' checkout ' or cmd == ' co ' :
r = get_request ( conf . config [ ' apiurl ' ] , reqid )
submits = [ i for i in r . actions if i . type == ' submit ' ]
if not len ( submits ) :
raise oscerr . WrongArgs ( ' \' checkout \' only works for \' submit \' requests ' )
checkout_package ( conf . config [ ' apiurl ' ] , submits [ 0 ] . src_project , submits [ 0 ] . src_package , \
submits [ 0 ] . src_rev , expand_link = True , prj_dir = submits [ 0 ] . src_project )
2008-03-05 00:41:00 +01:00
2009-08-19 13:28:16 +02:00
else :
if not opts . message :
opts . message = edit_message ( )
2009-12-23 20:51:08 +01:00
state_map = { ' accept ' : ' accepted ' , ' decline ' : ' declined ' , ' wipe ' : ' deleted ' , ' revoke ' : ' revoked ' }
2009-11-17 17:59:17 +01:00
# Change review state only
if subcmd == ' review ' :
2009-12-23 20:51:08 +01:00
if cmd in [ ' accept ' , ' decline ' ] :
r = change_review_state ( conf . config [ ' apiurl ' ] ,
reqid , state_map [ cmd ] , conf . config [ ' user ' ] , ' ' , opts . message or ' ' )
print r
2009-11-17 17:59:17 +01:00
# Change state of entire request
2009-12-23 20:51:08 +01:00
elif cmd in [ ' accept ' , ' decline ' , ' wipe ' , ' revoke ' ] :
r = change_request_state ( conf . config [ ' apiurl ' ] ,
reqid , state_map [ cmd ] , opts . message or ' ' )
print r
2008-03-05 00:41:00 +01:00
2007-07-16 18:20:09 +02:00
# editmeta and its aliases are all depracated
@cmdln.alias ( " editprj " )
@cmdln.alias ( " createprj " )
@cmdln.alias ( " editpac " )
@cmdln.alias ( " createpac " )
@cmdln.alias ( " edituser " )
@cmdln.alias ( " usermeta " )
2009-06-02 15:14:46 +02:00
@cmdln.hide ( 1 )
2007-07-16 18:20:09 +02:00
def do_editmeta ( self , subcmd , opts , * args ) :
2009-05-18 16:50:43 +02:00
""" $ {cmd_name} :
2007-07-16 18:20:09 +02:00
Obsolete command to edit metadata . Use ' meta ' now .
See the help output of ' meta ' .
2007-07-13 18:01:02 +02:00
2007-07-16 18:20:09 +02:00
"""
2007-07-13 18:01:02 +02:00
2007-07-16 18:20:09 +02:00
print >> sys . stderr , ' This command is obsolete. Use \' osc meta <metatype> ... \' . '
print >> sys . stderr , ' See \' osc help meta \' . '
#self.do_help([None, 'meta'])
return 2
2007-07-13 18:01:02 +02:00
2009-04-09 10:21:12 +02:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' rev ' ,
help = ' use the specified revision. ' )
2009-06-18 11:18:17 +02:00
@cmdln.option ( ' -u ' , ' --unset ' , action = ' store_true ' ,
help = ' remove revision in link, it will point always to latest revision ' )
2009-04-09 10:21:12 +02:00
def do_setlinkrev ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Updates a revision number in a source link.
2009-05-18 16:50:43 +02:00
2009-04-09 10:21:12 +02:00
This command adds or updates a specified revision number in a source link .
The current revision of the source is used , if no revision number is specified .
2009-05-18 16:50:43 +02:00
usage :
2009-04-09 10:21:12 +02:00
osc setlinkrev
2009-06-18 11:18:17 +02:00
osc setlinkrev PROJECT [ PACKAGE ]
2009-04-09 10:21:12 +02:00
$ { cmd_option_list }
"""
args = slash_split ( args )
2009-04-09 13:44:32 +02:00
apiurl = conf . config [ ' apiurl ' ]
2009-06-18 11:18:17 +02:00
package = None
2010-02-09 00:08:21 +01:00
if len ( args ) == 0 :
2009-04-09 10:21:12 +02:00
p = findpacs ( os . curdir ) [ 0 ]
project = p . prjname
package = p . name
2009-04-09 13:44:32 +02:00
apiurl = p . apiurl
if not p . islink ( ) :
2009-04-16 10:13:55 +02:00
sys . exit ( ' Local directory is no checked out source link package, aborting ' )
2009-04-09 10:21:12 +02:00
elif len ( args ) == 2 :
project = args [ 0 ]
package = args [ 1 ]
2009-06-18 11:18:17 +02:00
elif len ( args ) == 1 :
project = args [ 0 ]
2009-04-09 10:21:12 +02:00
else :
raise oscerr . WrongArgs ( ' Incorrect number of arguments. \n \n ' \
+ self . get_cmd_help ( ' setlinkrev ' ) )
2009-06-18 11:18:17 +02:00
if package :
packages = [ package ]
else :
packages = meta_get_packagelist ( apiurl , project )
for p in packages :
print " setting revision for package " , p
if opts . unset :
2009-10-20 16:30:15 +02:00
rev = - 1
2009-06-18 11:18:17 +02:00
else :
2009-10-20 16:30:15 +02:00
rev , dummy = parseRevisionOption ( opts . revision )
2009-06-18 11:18:17 +02:00
set_link_rev ( apiurl , project , p , rev )
2009-04-09 10:21:12 +02:00
2010-01-11 16:36:33 +01:00
def do_linktobranch ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Convert a package containing a classic link with patch to a branch
This command tells the server to convert a _link with or without a project . diff
to a branch . This is a full copy with a _link file pointing to the branched place .
usage :
2010-01-14 12:24:48 +01:00
osc linktobranch # can be used in checked out package
osc linktobranch PROJECT PACKAGE
2010-01-11 16:36:33 +01:00
$ { cmd_option_list }
"""
args = slash_split ( args )
2010-01-14 12:24:48 +01:00
if len ( args ) == 0 :
wd = os . curdir
project = store_read_project ( wd )
package = store_read_package ( wd )
apiurl = store_read_apiurl ( wd )
2010-01-14 20:25:14 +01:00
update_local_dir = True
2010-01-14 12:24:48 +01:00
elif len ( args ) < 2 :
raise oscerr . WrongArgs ( ' Too few arguments (required none or two) ' )
elif len ( args ) > 2 :
raise oscerr . WrongArgs ( ' Too many arguments (required none or two) ' )
else :
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
package = args [ 1 ]
2010-01-14 20:25:14 +01:00
update_local_dir = False
2010-01-11 16:36:33 +01:00
2010-01-14 12:24:48 +01:00
# execute
link_to_branch ( apiurl , project , package )
2010-01-14 20:25:14 +01:00
if update_local_dir :
2010-02-18 14:14:31 +01:00
pac = Package ( wd )
pac . update ( rev = pac . latest_rev ( ) )
2010-01-11 16:36:33 +01:00
2009-05-13 09:59:01 +02:00
@cmdln.option ( ' -C ' , ' --cicount ' , choices = [ ' add ' , ' copy ' , ' local ' ] ,
help = ' cicount attribute in the link, known values are add, copy, and local, default in buildservice is currently add. ' )
2009-06-18 11:18:17 +02:00
@cmdln.option ( ' -c ' , ' --current ' , action = ' store_true ' ,
help = ' link fixed against current revision. ' )
2008-06-26 12:47:58 +02:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' rev ' ,
help = ' link the specified revision. ' )
2009-06-15 17:19:16 +02:00
@cmdln.option ( ' -f ' , ' --force ' , action = ' store_true ' ,
help = ' overwrite an existing link file if it is there. ' )
2009-12-21 14:24:33 +01:00
@cmdln.option ( ' -d ' , ' --disable-publish ' , action = ' store_true ' ,
help = ' disable publishing of the linked package ' )
2007-04-25 01:00:12 +02:00
def do_linkpac ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : " Link " a package to another package
2009-05-18 16:50:43 +02:00
2007-04-25 01:00:12 +02:00
A linked package is a clone of another package , but plus local
modifications . It can be cross - project .
2006-08-07 12:08:54 +02:00
2007-04-25 01:00:12 +02:00
The DESTPAC name is optional ; the source packages ' name will be used if
DESTPAC is omitted .
2006-08-07 12:08:54 +02:00
2007-04-25 01:00:12 +02:00
Afterwards , you will want to ' checkout DESTPRJ DESTPAC ' .
2006-08-07 12:08:54 +02:00
2007-04-25 01:00:12 +02:00
To add a patch , add the patch as file and add it to the _link file .
You can also specify text which will be inserted at the top of the spec file .
2006-08-07 12:08:54 +02:00
2007-04-25 01:00:12 +02:00
See the examples in the _link file .
2006-08-07 12:08:54 +02:00
2009-05-18 16:50:43 +02:00
usage :
2007-04-25 01:00:12 +02:00
osc linkpac SOURCEPRJ SOURCEPAC DESTPRJ [ DESTPAC ]
$ { cmd_option_list }
"""
2006-08-07 12:08:54 +02:00
2007-06-26 15:17:38 +02:00
args = slash_split ( args )
2007-04-25 01:00:12 +02:00
if not args or len ( args ) < 3 :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Incorrect number of arguments. \n \n ' \
+ self . get_cmd_help ( ' linkpac ' ) )
2006-08-07 12:08:54 +02:00
2008-06-26 12:47:58 +02:00
rev , dummy = parseRevisionOption ( opts . revision )
2007-04-25 01:00:12 +02:00
src_project = args [ 0 ]
src_package = args [ 1 ]
dst_project = args [ 2 ]
if len ( args ) > 3 :
dst_package = args [ 3 ]
else :
dst_package = src_package
2006-09-21 16:33:24 +02:00
2007-04-25 01:00:12 +02:00
if src_project == dst_project and src_package == dst_package :
2010-01-09 14:25:41 +01:00
raise oscerr . WrongArgs ( ' Error: source and destination are the same. ' )
2008-06-26 12:47:58 +02:00
2009-11-02 22:02:58 +01:00
if src_project == dst_project and not opts . cicount :
# in this case, the user usually wants to build different spec
# files from the same source
opts . cicount = " copy "
2009-04-08 13:48:34 +02:00
if opts . current :
2009-10-20 16:30:15 +02:00
rev = show_upstream_rev ( conf . config [ ' apiurl ' ] , src_project , src_package )
2009-04-08 13:48:34 +02:00
2008-06-26 12:47:58 +02:00
if rev and not checkRevision ( src_project , src_package , rev ) :
print >> sys . stderr , ' Revision \' %s \' does not exist ' % rev
sys . exit ( 1 )
2009-12-21 14:24:33 +01:00
link_pac ( src_project , src_package , dst_project , dst_package , opts . force , rev , opts . cicount , opts . disable_publish )
2006-09-21 16:33:24 +02:00
2009-07-31 16:31:20 +02:00
@cmdln.option ( ' -m ' , ' --map-repo ' , metavar = ' SRC=TARGET[,SRC=TARGET] ' ,
help = ' Allows repository mapping(s) to be given as SRC=TARGET[,SRC=TARGET] ' )
2009-12-21 14:24:33 +01:00
@cmdln.option ( ' -d ' , ' --disable-publish ' , action = ' store_true ' ,
help = ' disable publishing of the aggregated package ' )
2007-10-30 14:45:54 +01:00
def do_aggregatepac ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : " Aggregate " a package to another package
2009-05-18 16:50:43 +02:00
2008-07-17 19:46:21 +02:00
Aggregation of a package means that the build results ( binaries ) of a
package are basically copied into another project .
This can be used to make packages available from building that are
needed in a project but available only in a different project . Note
2009-05-18 16:50:43 +02:00
that this is done at the expense of disk space . See
2008-07-17 19:46:21 +02:00
http : / / en . opensuse . org / Build_Service / Tips_and_Tricks #_link_and__aggregate
for more information .
2007-10-30 14:45:54 +01:00
The DESTPAC name is optional ; the source packages ' name will be used if
DESTPAC is omitted .
2009-05-18 16:50:43 +02:00
usage :
2007-10-30 14:45:54 +01:00
osc aggregatepac SOURCEPRJ SOURCEPAC DESTPRJ [ DESTPAC ]
$ { cmd_option_list }
"""
args = slash_split ( args )
if not args or len ( args ) < 3 :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Incorrect number of arguments. \n \n ' \
+ self . get_cmd_help ( ' aggregatepac ' ) )
2007-10-30 14:45:54 +01:00
src_project = args [ 0 ]
src_package = args [ 1 ]
dst_project = args [ 2 ]
if len ( args ) > 3 :
dst_package = args [ 3 ]
else :
dst_package = src_package
if src_project == dst_project and src_package == dst_package :
2010-01-09 14:25:41 +01:00
raise oscerr . WrongArgs ( ' Error: source and destination are the same. ' )
2009-07-31 16:31:20 +02:00
repo_map = { }
if opts . map_repo :
for pair in opts . map_repo . split ( ' , ' ) :
src_tgt = pair . split ( ' = ' )
if len ( src_tgt ) != 2 :
2010-01-09 14:25:41 +01:00
raise oscerr . WrongOptions ( ' map " %s " must be SRC=TARGET[,SRC=TARGET] ' % opts . map_repo )
2009-07-31 16:31:20 +02:00
repo_map [ src_tgt [ 0 ] ] = src_tgt [ 1 ]
2009-12-21 14:24:33 +01:00
aggregate_pac ( src_project , src_package , dst_project , dst_package , repo_map , opts . disable_publish )
2006-09-21 16:33:24 +02:00
2008-05-21 17:49:00 +02:00
2008-04-02 16:36:23 +02:00
@cmdln.option ( ' -c ' , ' --client-side-copy ' , action = ' store_true ' ,
help = ' do a (slower) client-side copy ' )
2008-04-30 14:28:25 +02:00
@cmdln.option ( ' -k ' , ' --keep-maintainers ' , action = ' store_true ' ,
help = ' keep original maintainers. Default is remove all and replace with the one calling the script. ' )
2009-03-11 16:23:23 +01:00
@cmdln.option ( ' -d ' , ' --keep-develproject ' , action = ' store_true ' ,
help = ' keep develproject tag in the package metadata ' )
2009-05-14 13:50:53 +02:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' rev ' ,
2009-08-20 21:28:05 +02:00
help = ' link the specified revision. ' )
2007-05-04 23:51:54 +02:00
@cmdln.option ( ' -t ' , ' --to-apiurl ' , metavar = ' URL ' ,
help = ' URL of destination api server. Default is the source api server. ' )
2009-05-14 13:50:53 +02:00
@cmdln.option ( ' -m ' , ' --message ' , metavar = ' TEXT ' ,
help = ' specify message TEXT ' )
2009-03-31 00:17:18 +02:00
@cmdln.option ( ' -e ' , ' --expand ' , action = ' store_true ' ,
help = ' if the source package is a link then copy the expanded version of the link ' )
2007-04-25 01:00:12 +02:00
def do_copypac ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Copy a package
2006-09-21 16:33:24 +02:00
2009-05-18 16:50:43 +02:00
A way to copy package to somewhere else .
2008-04-02 16:36:23 +02:00
It can be done across buildservice instances , if the - t option is used .
In that case , a client - side copy is implied .
Using - - client - side - copy always involves downloading all files , and
uploading them to the target .
2006-09-21 16:33:24 +02:00
2007-04-25 01:00:12 +02:00
The DESTPAC name is optional ; the source packages ' name will be used if
DESTPAC is omitted .
2006-09-21 16:33:24 +02:00
2009-05-18 16:50:43 +02:00
usage :
2007-04-25 01:00:12 +02:00
osc copypac SOURCEPRJ SOURCEPAC DESTPRJ [ DESTPAC ]
$ { cmd_option_list }
"""
2006-09-21 16:33:24 +02:00
2007-06-26 15:17:38 +02:00
args = slash_split ( args )
2007-04-25 01:00:12 +02:00
if not args or len ( args ) < 3 :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Incorrect number of arguments. \n \n ' \
+ self . get_cmd_help ( ' copypac ' ) )
2006-09-21 16:33:24 +02:00
2007-04-25 01:00:12 +02:00
src_project = args [ 0 ]
src_package = args [ 1 ]
dst_project = args [ 2 ]
if len ( args ) > 3 :
dst_package = args [ 3 ]
else :
dst_package = src_package
2006-09-21 16:33:24 +02:00
2007-05-04 23:51:54 +02:00
src_apiurl = conf . config [ ' apiurl ' ]
if opts . to_apiurl :
2009-12-15 17:24:25 +01:00
dst_apiurl = conf . config [ ' apiurl_aliases ' ] . get ( opts . to_apiurl , opts . to_apiurl )
2007-05-04 23:51:54 +02:00
else :
dst_apiurl = src_apiurl
if src_project == dst_project and \
src_package == dst_package and \
src_apiurl == dst_apiurl :
2009-10-20 16:30:15 +02:00
raise oscerr . WrongArgs ( ' Source and destination are the same. ' )
2008-03-17 22:46:42 +01:00
2008-04-02 16:36:23 +02:00
if src_apiurl != dst_apiurl :
opts . client_side_copy = True
2008-03-17 22:46:42 +01:00
2009-05-14 13:50:53 +02:00
rev , dummy = parseRevisionOption ( opts . revision )
if opts . message :
2009-07-15 20:53:47 +02:00
comment = opts . message
else :
2009-08-20 21:28:05 +02:00
if not rev :
2009-10-20 16:30:15 +02:00
rev = show_upstream_rev ( src_apiurl , src_project , src_package )
2009-07-15 20:53:47 +02:00
comment = ' osc copypac from project: %s package: %s revision: %s ' % ( src_project , src_package , rev )
2009-05-14 13:50:53 +02:00
2009-05-18 16:50:43 +02:00
r = copy_pac ( src_apiurl , src_project , src_package ,
2008-03-17 22:46:42 +01:00
dst_apiurl , dst_project , dst_package ,
2008-04-30 14:28:25 +02:00
client_side_copy = opts . client_side_copy ,
2009-03-11 16:23:23 +01:00
keep_maintainers = opts . keep_maintainers ,
2009-03-31 00:17:18 +02:00
keep_develproject = opts . keep_develproject ,
2009-05-14 13:50:53 +02:00
expand = opts . expand ,
revision = rev ,
comment = comment )
2008-03-17 22:46:42 +01:00
print r
2006-08-11 12:37:29 +02:00
2009-11-02 09:32:15 +01:00
@cmdln.option ( ' -c ' , ' --checkout ' , action = ' store_true ' ,
help = ' Checkout branched package afterwards ' \
' ( \' osc bco \' is a shorthand for this option) ' )
@cmdln.option ( ' -a ' , ' --attribute ' , metavar = ' ATTRIBUTE ' ,
help = ' Use this attribute to find affected packages (default is OBS:Maintained) ' )
@cmdln.option ( ' -u ' , ' --update-project-attribute ' , metavar = ' UPDATE_ATTRIBUTE ' ,
help = ' Use this attribute to find update projects (default is OBS:UpdateProject) ' )
def do_mbranch ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Multiple branch of a package
[ See http : / / en . opensuse . org / Build_Service / Concepts / Maintenance for information
on this topic . ]
This command is used for creating multiple links of defined version of a package
in one project . This is esp . used for maintenance updates .
The branched package will live in
home : USERNAME : branches : ATTRIBUTE : PACKAGE
if nothing else specified .
usage :
osc mbranch [ SOURCEPACKAGE [ TARGETPROJECT ] ]
$ { cmd_option_list }
"""
args = slash_split ( args )
tproject = None
maintained_attribute = conf . config [ ' maintained_attribute ' ]
maintained_update_project_attribute = conf . config [ ' maintained_update_project_attribute ' ]
2010-02-09 00:08:21 +01:00
if not len ( args ) or len ( args ) > 2 :
2009-11-02 09:32:15 +01:00
raise oscerr . WrongArgs ( ' Wrong number of arguments. ' )
if len ( args ) > = 1 :
package = args [ 0 ]
if len ( args ) > = 2 :
tproject = args [ 1 ]
r = attribute_branch_pkg ( conf . config [ ' apiurl ' ] , maintained_attribute , maintained_update_project_attribute , \
package , tproject )
if r is None :
2010-02-28 02:30:13 +01:00
print >> sys . stderr , ' ERROR: Attribute branch call came not back with a project. '
2009-11-02 09:32:15 +01:00
sys . exit ( 1 )
print " Project " + r + " created. "
if opts . checkout :
init_project_dir ( conf . config [ ' apiurl ' ] , r , r )
print statfrmt ( ' A ' , r )
# all packages
for package in meta_get_packagelist ( conf . config [ ' apiurl ' ] , r ) :
try :
checkout_package ( conf . config [ ' apiurl ' ] , r , package , expand_link = True , prj_dir = r )
except :
print >> sys . stderr , ' Error while checkout package: \n ' , package
if conf . config [ ' verbose ' ] :
print ' Note: You can use " osc delete " or " osc submitpac " when done. \n '
2009-08-20 21:28:05 +02:00
@cmdln.alias ( ' branchco ' )
@cmdln.alias ( ' bco ' )
@cmdln.alias ( ' getpac ' )
2008-06-03 15:16:55 +02:00
@cmdln.option ( ' --nodevelproject ' , action = ' store_true ' ,
help = ' do not follow a defined devel project ' \
' (primary project where a package is developed) ' )
2009-04-17 14:02:02 +02:00
@cmdln.option ( ' -c ' , ' --checkout ' , action = ' store_true ' ,
2009-08-20 21:28:05 +02:00
help = ' Checkout branched package afterwards ' \
' ( \' osc bco \' is a shorthand for this option) ' )
2009-02-10 16:49:34 +01:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' rev ' ,
help = ' branch against a specific revision ' )
2010-03-02 01:34:17 +01:00
@cmdln.option ( ' -m ' , ' --message ' , metavar = ' TEXT ' ,
help = ' specify message TEXT ' )
2008-10-16 14:34:41 +02:00
def do_branch ( self , subcmd , opts , * args ) :
2008-05-21 17:49:00 +02:00
""" $ {cmd_name} : Branch a package
2008-06-06 14:04:34 +02:00
[ See http : / / en . opensuse . org / Build_Service / Collaboration for information
on this topic . ]
2008-05-21 17:49:00 +02:00
Create a source link from a package of an existing project to a new
subproject of the requesters home project ( home : branches : )
The branched package will live in
home : USERNAME : branches : PROJECT / PACKAGE
2009-04-17 14:02:02 +02:00
if nothing else specified .
2009-05-18 16:50:43 +02:00
2009-10-20 16:30:15 +02:00
With getpac or bco , the branched package will come from
2009-09-03 23:32:36 +02:00
% ( getpac_default_project ) s
2009-09-03 20:08:43 +02:00
if nothing else specified .
2009-05-18 16:50:43 +02:00
usage :
2009-04-17 14:02:02 +02:00
osc branch SOURCEPROJECT SOURCEPACKAGE
osc branch SOURCEPROJECT SOURCEPACKAGE TARGETPROJECT
osc branch SOURCEPROJECT SOURCEPACKAGE TARGETPROJECT TARGETPACKAGE
2009-09-03 20:08:43 +02:00
osc getpac SOURCEPACKAGE
2009-08-20 21:28:05 +02:00
osc bco . . .
2008-05-21 17:49:00 +02:00
$ { cmd_option_list }
"""
2009-09-03 20:08:43 +02:00
if subcmd == ' getpac ' or subcmd == ' branchco ' or subcmd == ' bco ' : opts . checkout = True
2008-10-16 14:34:41 +02:00
args = slash_split ( args )
2009-04-17 14:02:02 +02:00
tproject = tpackage = None
2009-08-20 21:28:05 +02:00
2009-09-03 23:32:36 +02:00
if ( subcmd == ' getpac ' or subcmd == ' bco ' ) and len ( args ) == 1 :
print >> sys . stderr , ' defaulting to %s / %s ' % ( conf . config [ ' getpac_default_project ' ] , args [ 0 ] )
2009-09-03 20:08:43 +02:00
# python has no args.unshift ???
args = [ conf . config [ ' getpac_default_project ' ] , args [ 0 ] ]
2010-02-08 23:31:27 +01:00
if len ( args ) < 2 or len ( args ) > 4 :
2008-10-16 14:34:41 +02:00
raise oscerr . WrongArgs ( ' Wrong number of arguments. ' )
2010-01-19 19:15:45 +01:00
expected = ' home: %s :branches: %s ' % ( conf . config [ ' user ' ] , args [ 0 ] )
2009-04-17 14:02:02 +02:00
if len ( args ) > = 3 :
2010-01-15 10:29:07 +01:00
expected = tproject = args [ 2 ]
2009-04-17 14:02:02 +02:00
if len ( args ) > = 4 :
tpackage = args [ 3 ]
2008-10-16 14:34:41 +02:00
2010-03-09 15:30:06 +01:00
if not opts . message :
footer = ' please specify the purpose of your branch '
template = ' This package was branched from %s in order to ... \n ' % args [ 0 ]
opts . message = edit_message ( footer , template )
2010-02-08 19:58:14 +01:00
exists , targetprj , targetpkg , srcprj , srcpkg = \
branch_pkg ( conf . config [ ' apiurl ' ] , args [ 0 ] , args [ 1 ] ,
2009-10-20 16:30:15 +02:00
nodevelproject = opts . nodevelproject , rev = opts . revision ,
target_project = tproject , target_package = tpackage ,
2010-03-02 01:34:17 +01:00
return_existing = opts . checkout , msg = opts . message or ' ' )
2010-02-08 19:58:14 +01:00
if exists :
print >> sys . stderr , ' Using existing branch project: %s ' % targetprj
2009-08-20 21:28:05 +02:00
2009-09-23 01:31:10 +02:00
devloc = None
2010-02-08 19:58:14 +01:00
if not exists and ( srcprj is not None and srcprj != args [ 0 ] or \
srcprj is None and targetprj != expected ) :
devloc = srcprj or targetprj
if not srcprj and ' branches: ' in targetprj :
devloc = targetprj . split ( ' branches: ' ) [ 1 ]
2008-06-03 15:16:55 +02:00
print ' \n Note: The branch has been created of a different project, \n ' \
' %s , \n ' \
' which is the primary location of where development for \n ' \
' that package takes place. \n ' \
' That \' s also where you would normally make changes against. \n ' \
' A direct branch of the specified package can be forced \n ' \
' with the --nodevelproject option. \n ' % devloc
2009-04-17 14:02:02 +02:00
2010-02-08 19:58:14 +01:00
package = tpackage or args [ 1 ]
2009-04-17 14:02:02 +02:00
if opts . checkout :
2010-02-08 19:58:14 +01:00
checkout_package ( conf . config [ ' apiurl ' ] , targetprj , package ,
expand_link = True , prj_dir = targetprj )
2009-08-20 21:28:05 +02:00
if conf . config [ ' verbose ' ] :
print ' Note: You can use " osc delete " or " osc submitpac " when done. \n '
2009-04-17 14:02:02 +02:00
else :
apiopt = ' '
if conf . get_configParser ( ) . get ( ' general ' , ' apiurl ' ) != conf . config [ ' apiurl ' ] :
apiopt = ' -A %s ' % conf . config [ ' apiurl ' ]
print ' A working copy of the branched package can be checked out with: \n \n ' \
' osc %s co %s / %s ' \
2010-02-08 19:58:14 +01:00
% ( apiopt , targetprj , package )
2009-09-23 01:31:10 +02:00
print_request_list ( conf . config [ ' apiurl ' ] , args [ 0 ] , args [ 1 ] )
if devloc :
print_request_list ( conf . config [ ' apiurl ' ] , devloc , args [ 1 ] )
2008-05-21 17:49:00 +02:00
2009-05-18 16:50:43 +02:00
2006-08-11 12:37:29 +02:00
2007-10-14 01:15:49 +02:00
@cmdln.option ( ' -f ' , ' --force ' , action = ' store_true ' ,
2009-08-20 21:28:05 +02:00
help = ' deletes a package or an empty project ' )
2009-05-04 21:07:05 +02:00
def do_rdelete ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Delete a project or packages on the server.
2006-09-25 17:11:03 +02:00
2007-10-14 01:15:49 +02:00
As a safety measure , project must be empty ( i . e . , you need to delete all
packages first ) . If you are sure that you want to remove this project and all
its packages use \' --force \' switch.
2006-09-25 17:11:03 +02:00
2009-05-04 21:07:05 +02:00
usage :
osc rdelete - f PROJECT
osc rdelete PROJECT PACKAGE [ PACKAGE . . . ]
2007-05-08 10:59:10 +02:00
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2006-09-25 17:11:03 +02:00
2009-05-04 21:07:05 +02:00
args = slash_split ( args )
2009-05-07 21:41:02 +02:00
if len ( args ) < 1 :
raise oscerr . WrongArgs ( ' Missing argument. ' )
2009-05-04 21:07:05 +02:00
prj = args [ 0 ]
pkgs = args [ 1 : ]
if pkgs :
2009-10-20 16:30:15 +02:00
for pkg in pkgs :
2009-05-04 21:07:05 +02:00
# careful: if pkg is an empty string, the package delete request results
# into a project delete request - which works recursively...
2009-10-20 16:30:15 +02:00
if pkg :
delete_package ( conf . config [ ' apiurl ' ] , prj , pkg )
2009-05-06 12:08:08 +02:00
elif len ( meta_get_packagelist ( conf . config [ ' apiurl ' ] , prj ) ) > = 1 and not opts . force :
2007-10-14 01:15:49 +02:00
print >> sys . stderr , ' Project contains packages. It must be empty before deleting it. ' \
' If you are sure that you want to remove this project and all its ' \
' packages use the \' --force \' switch '
sys . exit ( 1 )
else :
2009-05-04 21:07:05 +02:00
delete_project ( conf . config [ ' apiurl ' ] , prj )
@cmdln.hide ( 1 )
def do_deletepac ( self , subcmd , opts , * args ) :
2009-05-11 15:21:33 +02:00
print """ $ {cmd_name} is obsolete !
Please use either
2009-05-04 21:07:05 +02:00
osc delete for checked out packages or projects
or
osc rdelete for server side operations . """
sys . exit ( 1 )
@cmdln.hide ( 1 )
@cmdln.option ( ' -f ' , ' --force ' , action = ' store_true ' ,
help = ' deletes a project and its packages ' )
def do_deleteprj ( self , subcmd , opts , project ) :
""" $ {cmd_name} is obsolete !
2006-09-25 17:11:03 +02:00
2009-05-04 21:07:05 +02:00
Please use
osc rdelete PROJECT
"""
sys . exit ( 1 )
2006-09-25 17:11:03 +02:00
2008-08-08 17:23:03 +02:00
@cmdln.alias ( ' metafromspec ' )
2007-06-30 17:39:47 +02:00
@cmdln.option ( ' ' , ' --specfile ' , metavar = ' FILE ' ,
help = ' Path to specfile. (if you pass more than working copy this option is ignored) ' )
2007-04-25 01:00:12 +02:00
def do_updatepacmetafromspec ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Update package meta information from a specfile
2006-09-25 17:11:03 +02:00
2007-04-25 01:00:12 +02:00
ARG , if specified , is a package working copy .
2006-09-25 17:11:03 +02:00
2007-04-25 01:00:12 +02:00
$ { cmd_usage }
$ { cmd_option_list }
"""
2006-05-31 14:13:26 +02:00
2007-04-25 01:00:12 +02:00
args = parseargs ( args )
2010-02-09 00:08:21 +01:00
if opts . specfile and len ( args ) == 1 :
2007-06-30 17:39:47 +02:00
specfile = opts . specfile
else :
specfile = None
2007-04-25 01:00:12 +02:00
pacs = findpacs ( args )
for p in pacs :
2007-06-30 17:39:47 +02:00
p . read_meta_from_spec ( specfile )
2007-07-16 15:40:58 +02:00
p . update_package_meta ( )
2006-05-31 14:13:26 +02:00
2007-04-25 01:00:12 +02:00
@cmdln.alias ( ' di ' )
2009-05-18 16:50:43 +02:00
@cmdln.option ( ' -c ' , ' --change ' , metavar = ' rev ' ,
help = ' the change made by revision rev (like -r rev-1:rev). '
' If rev is negative this is like -r rev:rev-1. ' )
2007-07-04 14:55:26 +02:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' rev1[:rev2] ' ,
help = ' If rev1 is specified it will compare your working copy against '
' the revision (rev1) on the server. '
2009-01-09 18:09:29 +01:00
' If rev1 and rev2 are specified it will compare rev1 against rev2 '
2009-01-16 15:45:27 +01:00
' (NOTE: changes in your working copy are ignored in this case) ' )
2009-09-07 20:49:01 +02:00
@cmdln.option ( ' -p ' , ' --plain ' , action = ' store_true ' ,
help = ' output the diff in plain (not unified) diff format ' )
2010-04-10 15:44:15 +02:00
@cmdln.option ( ' --missingok ' , action = ' store_true ' ,
help = ' do not fail if the source or target project/package does not exist on the server ' )
2007-04-25 01:00:12 +02:00
def do_diff ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Generates a diff
2006-05-31 14:13:26 +02:00
2007-04-25 01:00:12 +02:00
Generates a diff , comparing local changes against the repository
server .
2009-05-18 16:50:43 +02:00
2007-04-25 01:00:12 +02:00
ARG , specified , is a filename to include in the diff .
$ { cmd_usage }
$ { cmd_option_list }
"""
args = parseargs ( args )
pacs = findpacs ( args )
2009-05-18 16:50:43 +02:00
if opts . change :
try :
rev = int ( opts . change )
if rev > 0 :
rev1 = rev - 1
rev2 = rev
elif rev < 0 :
rev1 = - rev
rev2 = - rev - 1
else :
return
except :
2009-09-07 20:49:01 +02:00
print >> sys . stderr , ' Revision \' %s \' not an integer ' % opts . change
2009-05-18 16:50:43 +02:00
return
else :
rev1 , rev2 = parseRevisionOption ( opts . revision )
2007-11-26 19:13:51 +01:00
diff = ' '
for pac in pacs :
2009-01-09 18:09:29 +01:00
if not rev2 :
diff + = ' ' . join ( make_diff ( pac , rev1 ) )
else :
2009-01-16 15:43:45 +01:00
diff + = server_diff ( pac . apiurl , pac . prjname , pac . name , rev1 ,
2010-04-10 15:44:15 +02:00
pac . prjname , pac . name , rev2 , not opts . plain , opts . missingok )
2007-11-26 19:13:51 +01:00
if len ( diff ) > 0 :
print diff
2007-07-04 14:55:26 +02:00
2007-04-25 01:00:12 +02:00
2007-11-29 18:22:57 +01:00
@cmdln.option ( ' --oldprj ' , metavar = ' OLDPRJ ' ,
2010-01-10 12:12:26 +01:00
help = ' project to compare against '
' (deprecated, use 3 argument form) ' )
2007-11-29 18:22:57 +01:00
@cmdln.option ( ' --oldpkg ' , metavar = ' OLDPKG ' ,
2010-01-10 12:12:26 +01:00
help = ' package to compare against '
' (deprecated, use 3 argument form) ' )
2007-11-29 18:22:57 +01:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' N[:M] ' ,
help = ' revision id, where N = old revision and M = new revision ' )
2009-09-07 20:49:01 +02:00
@cmdln.option ( ' -p ' , ' --plain ' , action = ' store_true ' ,
help = ' output the diff in plain (not unified) diff format ' )
@cmdln.option ( ' -c ' , ' --change ' , metavar = ' rev ' ,
2010-01-10 12:12:26 +01:00
help = ' the change made by revision rev (like -r rev-1:rev). '
2009-09-07 20:49:01 +02:00
' If rev is negative this is like -r rev:rev-1. ' )
2010-04-10 15:44:15 +02:00
@cmdln.option ( ' --missingok ' , action = ' store_true ' ,
help = ' do not fail if the source or target project/package does not exist on the server ' )
2010-01-10 12:12:26 +01:00
def do_rdiff ( self , subcmd , opts , * args ) :
2007-12-10 15:23:58 +01:00
""" $ {cmd_name} : Server-side " pretty " diff of two packages
2007-11-29 18:22:57 +01:00
2010-01-10 12:12:26 +01:00
Compares two packages ( three or four arguments ) or shows the
changes of a specified revision of a package ( two arguments )
If no revision is specified the latest revision is used .
2007-11-29 18:32:52 +01:00
2009-07-27 22:03:01 +02:00
Note that this command doesn ' t return a normal diff (which could be
applied as patch ) , but a " pretty " diff , which also compares the content
of tarballs .
2007-11-29 18:32:52 +01:00
2007-11-29 18:22:57 +01:00
2010-01-10 12:12:26 +01:00
usage :
osc $ { cmd_name } OLDPRJ OLDPAC NEWPRJ [ NEWPAC ]
osc $ { cmd_name } PROJECT PACKAGE
2007-11-29 18:22:57 +01:00
$ { cmd_option_list }
"""
2010-01-10 12:12:26 +01:00
args = slash_split ( args )
2009-09-07 20:49:01 +02:00
rev1 = None
rev2 = None
2010-01-10 12:12:26 +01:00
old_project = None
old_package = None
new_project = None
new_package = None
if len ( args ) == 2 :
new_project = args [ 0 ]
new_package = args [ 1 ]
if opts . oldprj :
old_project = opts . oldprj
if opts . oldpkg :
old_package = opts . oldpkg
elif len ( args ) == 3 or len ( args ) == 4 :
if opts . oldprj or opts . oldpkg :
raise oscerr . WrongArgs ( ' --oldpkg and --oldprj are only valid with two arguments ' )
old_project = args [ 0 ]
2010-01-18 10:25:00 +01:00
new_package = old_package = args [ 1 ]
2010-01-10 12:12:26 +01:00
new_project = args [ 2 ]
if len ( args ) == 4 :
new_package = args [ 3 ]
else :
raise oscerr . WrongArgs ( ' Wrong number of arguments ' )
2009-09-07 20:49:01 +02:00
if opts . change :
try :
rev = int ( opts . change )
if rev > 0 :
rev1 = rev - 1
rev2 = rev
elif rev < 0 :
rev1 = - rev
rev2 = - rev - 1
else :
return
except :
print >> sys . stderr , ' Revision \' %s \' not an integer ' % opts . change
return
else :
if opts . revision :
rev1 , rev2 = parseRevisionOption ( opts . revision )
2007-11-29 18:22:57 +01:00
2009-01-16 15:43:45 +01:00
rdiff = server_diff ( conf . config [ ' apiurl ' ] ,
2010-01-10 12:12:26 +01:00
old_project , old_package , rev1 ,
2010-04-10 15:44:15 +02:00
new_project , new_package , rev2 , not opts . plain , opts . missingok )
2007-11-29 18:22:57 +01:00
print rdiff
2009-11-30 10:31:22 +01:00
@cmdln.hide ( 1 )
2009-10-08 16:40:06 +02:00
@cmdln.alias ( ' in ' )
2009-08-20 21:28:05 +02:00
def do_install ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : install a package after build via zypper in -r
2009-10-20 16:30:15 +02:00
Not implemented yet . Use osc repourls ,
select the url you best like ( standard ) ,
2009-08-20 21:28:05 +02:00
chop off after the last / , this should work with zypper .
2009-10-08 16:40:06 +02:00
2009-08-20 21:28:05 +02:00
$ { cmd_usage }
$ { cmd_option_list }
"""
2009-10-08 16:40:06 +02:00
args = slash_split ( args )
args = expand_proj_pack ( args )
2009-11-10 01:56:52 +01:00
2010-02-28 02:30:13 +01:00
## FIXME:
2009-11-10 01:56:52 +01:00
## if there is only one argument, and it ends in .ymp
2010-02-28 02:30:13 +01:00
## then fetch it, Parse XML to get the first
2009-11-10 01:56:52 +01:00
## metapackage.group.repositories.repository.url
## and construct zypper cmd's for all
## metapackage.group.software.item.name
##
## if args[0] is already an url, the use it as is.
2009-10-20 16:30:15 +02:00
cmd = " sudo zypper -p http://download.opensuse.org/repositories/ %s / %s --no-refresh -v in %s " % ( re . sub ( ' : ' , ' :/ ' , args [ 0 ] ) , ' openSUSE_11.1 ' , args [ 1 ] )
2009-08-20 21:28:05 +02:00
print self . do_install . __doc__
2009-10-20 16:30:15 +02:00
print " Example: \n " + cmd
2009-08-20 21:28:05 +02:00
2007-11-29 18:22:57 +01:00
2007-04-25 01:00:12 +02:00
def do_repourls ( self , subcmd , opts , * args ) :
2009-05-18 16:50:43 +02:00
""" $ {cmd_name} : Shows URLs of .repo files
2007-04-25 01:00:12 +02:00
Shows URLs on which to access the project . repos files ( yum - style
2007-07-16 11:45:17 +02:00
metadata ) on download . opensuse . org .
2006-05-23 15:48:58 +02:00
2009-11-30 10:31:28 +01:00
usage :
osc repourls [ PROJECT ]
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2006-05-23 15:48:58 +02:00
2009-11-30 10:31:28 +01:00
apiurl = conf . config [ ' apiurl ' ]
2007-03-12 16:46:15 +01:00
2009-11-30 10:31:28 +01:00
if len ( args ) == 1 :
project = args [ 0 ]
elif len ( args ) == 0 :
project = store_read_project ( ' . ' )
apiurl = store_read_apiurl ( ' . ' )
else :
raise oscerr . WrongArgs ( ' Wrong number of arguments ' )
2006-05-23 15:48:58 +02:00
2009-11-30 10:31:28 +01:00
# XXX: API should somehow tell that
url_tmpl = ' http://download.opensuse.org/repositories/ %s / %s / %s .repo '
repos = get_repositories_of_project ( apiurl , project )
for repo in repos :
print url_tmpl % ( project . replace ( ' : ' , ' :/ ' ) , repo , project )
2006-05-23 15:48:58 +02:00
2007-07-04 14:55:26 +02:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' rev ' ,
2007-07-04 15:48:24 +02:00
help = ' checkout the specified revision. '
' NOTE: if you checkout the complete project '
' this option is ignored! ' )
2008-03-24 21:24:49 +01:00
@cmdln.option ( ' -e ' , ' --expand-link ' , action = ' store_true ' ,
2009-05-18 16:50:43 +02:00
help = ' if a package is a link, check out the expanded '
2008-06-06 14:04:34 +02:00
' sources (no-op, since this became the default) ' )
@cmdln.option ( ' -u ' , ' --unexpand-link ' , action = ' store_true ' ,
help = ' if a package is a link, check out the _link file ' \
' instead of the expanded sources ' )
2009-04-16 19:41:47 +02:00
@cmdln.option ( ' -c ' , ' --current-dir ' , action = ' store_true ' ,
help = ' place PACKAGE folder in the current directory ' \
' instead of a PROJECT/PACKAGE directory ' )
2009-08-07 14:18:15 +02:00
@cmdln.option ( ' -s ' , ' --source-service-files ' , action = ' store_true ' ,
help = ' server side generated files of source services ' \
' gets downloaded as well ' )
2007-04-25 01:00:12 +02:00
@cmdln.alias ( ' co ' )
def do_checkout ( self , subcmd , opts , * args ) :
2007-12-10 15:23:58 +01:00
""" $ {cmd_name} : Check out content from the repository
2009-05-18 16:50:43 +02:00
2007-04-25 01:00:12 +02:00
Check out content from the repository server , creating a local working
copy .
2008-03-24 21:24:49 +01:00
When checking out a single package , the option - - revision can be used
2009-05-27 14:09:50 +02:00
to specify a revision of the package to be checked out .
2008-03-24 21:24:49 +01:00
2009-05-18 16:50:43 +02:00
When a package is a source link , then it will be checked out in
expanded form . If - - unexpand - link option is used , the checkout will
2008-06-06 14:04:34 +02:00
instead produce the raw _link file plus patches .
2007-04-25 01:00:12 +02:00
2009-05-18 16:50:43 +02:00
usage :
2007-04-25 01:00:12 +02:00
osc co PROJECT [ PACKAGE ] [ FILE ]
2009-04-17 10:39:04 +02:00
osc co PROJECT # entire project
osc co PROJECT PACKAGE # a package
osc co PROJECT PACKAGE FILE # single file -> to current dir
2009-04-24 01:59:40 +02:00
while inside a project directory :
osc co PACKAGE # check out PACKAGE from project
2009-04-17 10:39:04 +02:00
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2008-06-06 14:04:34 +02:00
2009-09-16 23:39:45 +02:00
if opts . unexpand_link :
expand_link = False
else :
expand_link = True
if opts . source_service_files :
service_files = True
else :
service_files = False
2008-06-06 14:04:34 +02:00
2007-06-26 15:17:38 +02:00
args = slash_split ( args )
2007-04-25 01:00:12 +02:00
project = package = filename = None
2009-04-17 10:39:04 +02:00
apiurl = conf . config [ ' apiurl ' ]
2009-05-18 16:50:43 +02:00
try :
2009-04-17 10:39:04 +02:00
project = project_dir = args [ 0 ]
2007-04-25 01:00:12 +02:00
package = args [ 1 ]
filename = args [ 2 ]
2009-05-18 16:50:43 +02:00
except :
2007-04-25 01:00:12 +02:00
pass
2009-04-17 10:39:04 +02:00
if args and len ( args ) == 1 :
2009-04-17 10:48:22 +02:00
localdir = os . getcwd ( )
if is_project_dir ( localdir ) :
2009-12-21 23:47:25 +01:00
project = store_read_project ( localdir )
2009-04-17 10:48:22 +02:00
project_dir = localdir
2009-04-17 10:39:04 +02:00
package = args [ 0 ]
2009-12-21 23:47:25 +01:00
apiurl = store_read_apiurl ( localdir )
2008-06-06 14:04:34 +02:00
2007-07-04 14:55:26 +02:00
rev , dummy = parseRevisionOption ( opts . revision )
2009-10-16 10:26:01 +02:00
if rev == None :
2009-10-20 16:30:15 +02:00
rev = " latest "
2007-07-04 14:55:26 +02:00
2009-10-16 10:26:01 +02:00
if rev and rev != " latest " and not checkRevision ( project , package , rev ) :
2007-07-06 13:54:34 +02:00
print >> sys . stderr , ' Revision \' %s \' does not exist ' % rev
sys . exit ( 1 )
2007-04-25 01:00:12 +02:00
if filename :
2010-02-09 20:57:10 +01:00
get_source_file ( apiurl , project , package , filename , revision = rev , progress_obj = self . download_progress )
2007-04-25 01:00:12 +02:00
elif package :
2009-09-16 23:39:45 +02:00
if opts . current_dir :
project_dir = None
2010-02-09 20:57:10 +01:00
checkout_package ( apiurl , project , package , rev , expand_link = expand_link , \
prj_dir = project_dir , service_files = service_files , progress_obj = self . download_progress )
2009-09-18 03:10:41 +02:00
print_request_list ( apiurl , project , package )
2007-04-25 01:00:12 +02:00
elif project :
2009-05-15 13:40:50 +02:00
prj_dir = project
2009-09-08 13:16:21 +02:00
if sys . platform [ : 3 ] == ' win ' :
2009-05-15 13:40:50 +02:00
prj_dir = prj_dir . replace ( ' : ' , ' ; ' )
if os . path . exists ( prj_dir ) :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
sys . exit ( ' osc: project \' %s \' already exists ' % project )
# check if the project does exist (show_project_meta will throw an exception)
2009-04-17 10:39:04 +02:00
show_project_meta ( apiurl , project )
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
2009-05-15 13:40:50 +02:00
init_project_dir ( apiurl , prj_dir , project )
print statfrmt ( ' A ' , prj_dir )
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
2007-04-25 01:00:12 +02:00
# all packages
2009-04-17 10:39:04 +02:00
for package in meta_get_packagelist ( apiurl , project ) :
2008-10-02 17:46:52 +02:00
try :
2010-02-09 20:57:10 +01:00
checkout_package ( apiurl , project , package , expand_link = expand_link , \
prj_dir = prj_dir , service_files = service_files , progress_obj = self . download_progress )
2008-10-02 17:46:52 +02:00
except oscerr . LinkExpandError , e :
print >> sys . stderr , ' Link cannot be expanded: \n ' , e
2009-04-22 14:32:29 +02:00
print >> sys . stderr , ' Use " osc repairlink " for fixing merge conflicts: \n '
2008-10-02 17:46:52 +02:00
# check out in unexpanded form at least
2010-02-09 20:57:10 +01:00
checkout_package ( apiurl , project , package , expand_link = False , \
prj_dir = prj_dir , service_files = service_files , progress_obj = self . download_progress )
2009-09-18 03:10:41 +02:00
print_request_list ( apiurl , project )
2008-10-02 17:46:52 +02:00
2007-04-25 01:00:12 +02:00
else :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Missing argument. \n \n ' \
+ self . get_cmd_help ( ' checkout ' ) )
2007-04-25 01:00:12 +02:00
2008-05-21 15:44:49 +02:00
@cmdln.option ( ' -q ' , ' --quiet ' , action = ' store_true ' ,
help = ' print as little as possible ' )
2007-04-25 01:00:12 +02:00
@cmdln.option ( ' -v ' , ' --verbose ' , action = ' store_true ' ,
help = ' print extra information ' )
@cmdln.alias ( ' st ' )
def do_status ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Show status of files in working copy
Show the status of files in a local working copy , indicating whether
files have been changed locally , deleted , added , . . .
The first column in the output specifies the status and is one of the
following characters :
' ' no modifications
' A ' Added
' C ' Conflicted
' D ' Deleted
' M ' Modified
' ? ' item is not under version control
2009-07-15 23:16:34 +02:00
' ! ' item is missing ( removed by non - osc command ) or incomplete
2007-04-25 01:00:12 +02:00
examples :
osc st
osc st < directory >
osc st file1 file2 . . .
2009-05-18 16:50:43 +02:00
usage :
2007-04-25 01:00:12 +02:00
osc status [ OPTS ] [ PATH . . . ]
$ { cmd_option_list }
"""
args = parseargs ( args )
2008-04-23 23:51:24 +02:00
# storage for single Package() objects
2007-04-25 01:00:12 +02:00
pacpaths = [ ]
2008-04-23 23:51:24 +02:00
# storage for a project dir ( { prj_instance : [ package objects ] } )
prjpacs = { }
2007-04-25 01:00:12 +02:00
for arg in args :
# when 'status' is run inside a project dir, it should
# stat all packages existing in the wc
if is_project_dir ( arg ) :
2008-03-10 19:04:23 +01:00
prj = Project ( arg , False )
if conf . config [ ' do_package_tracking ' ] :
2008-04-23 23:51:24 +02:00
prjpacs [ prj ] = [ ]
2008-03-10 19:04:23 +01:00
for pac in prj . pacs_have :
# we cannot create package objects if the dir does not exist
if not pac in prj . pacs_broken :
2008-04-23 23:51:24 +02:00
prjpacs [ prj ] . append ( os . path . join ( arg , pac ) )
2008-03-10 19:04:23 +01:00
else :
pacpaths + = [ arg + ' / ' + n for n in prj . pacs_have ]
2007-04-25 01:00:12 +02:00
elif is_package_dir ( arg ) :
pacpaths . append ( arg )
elif os . path . isfile ( arg ) :
pacpaths . append ( arg )
else :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
msg = ' \' %s \' is neither a project or a package directory ' % arg
raise oscerr . NoWorkingCopy , msg
2008-03-10 19:04:23 +01:00
lines = [ ]
2008-04-23 23:51:24 +02:00
# process single packages
2008-05-21 15:44:49 +02:00
lines = getStatus ( findpacs ( pacpaths ) , None , opts . verbose , opts . quiet )
2008-04-23 23:51:24 +02:00
# process project dirs
for prj , pacs in prjpacs . iteritems ( ) :
2008-05-21 15:44:49 +02:00
lines + = getStatus ( findpacs ( pacs ) , prj , opts . verbose , opts . quiet )
2008-03-10 19:04:23 +01:00
if lines :
print ' \n ' . join ( lines )
2006-06-02 16:00:58 +02:00
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
def do_add ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Mark files to be added upon the next commit
2006-05-23 15:48:58 +02:00
2009-05-18 16:50:43 +02:00
usage :
2007-04-25 01:00:12 +02:00
osc add FILE [ FILE . . . ]
$ { cmd_option_list }
"""
if not args :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Missing argument. \n \n ' \
+ self . get_cmd_help ( ' add ' ) )
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
filenames = parseargs ( args )
2008-03-10 19:04:23 +01:00
addFiles ( filenames )
2006-05-23 15:48:58 +02:00
2009-05-18 16:50:43 +02:00
2008-03-10 19:04:23 +01:00
def do_mkpac ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Create a new package under version control
2006-09-29 15:15:41 +02:00
2008-03-10 19:04:23 +01:00
usage :
osc mkpac new_package
$ { cmd_option_list }
"""
2008-03-18 00:43:32 +01:00
if not conf . config [ ' do_package_tracking ' ] :
2008-12-17 23:45:58 +01:00
print >> sys . stderr , " to use this feature you have to enable \' do_package_tracking \' " \
" in the [general] section in the configuration file "
2008-03-18 00:43:32 +01:00
sys . exit ( 1 )
2008-03-10 19:04:23 +01:00
if len ( args ) != 1 :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Wrong number of arguments. ' )
2008-03-15 23:51:37 +01:00
createPackageDir ( args [ 0 ] )
2006-05-23 15:48:58 +02:00
2008-08-20 21:24:55 +02:00
@cmdln.option ( ' -r ' , ' --recursive ' , action = ' store_true ' ,
help = ' If CWD is a project dir then scan all package dirs as well ' )
2009-05-11 15:21:33 +02:00
@cmdln.alias ( ' ar ' )
2007-04-25 01:00:12 +02:00
def do_addremove ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Adds new files, removes disappeared files
2006-04-20 16:26:50 +02:00
2007-04-25 01:00:12 +02:00
Adds all files new in the local copy , and removes all disappeared files .
2006-04-20 16:26:50 +02:00
2007-04-25 01:00:12 +02:00
ARG , if specified , is a package working copy .
2006-04-20 16:26:50 +02:00
2007-04-25 01:00:12 +02:00
$ { cmd_usage }
$ { cmd_option_list }
"""
2006-05-11 09:27:50 +02:00
2007-04-25 01:00:12 +02:00
args = parseargs ( args )
2008-08-20 21:24:55 +02:00
arg_list = args [ : ]
for arg in arg_list :
2009-03-16 22:29:42 +01:00
if is_project_dir ( arg ) and conf . config [ ' do_package_tracking ' ] :
2008-08-20 21:24:55 +02:00
prj = Project ( arg , False )
for pac in prj . pacs_unvers :
pac_dir = getTransActPath ( os . path . join ( prj . dir , pac ) )
if os . path . isdir ( pac_dir ) :
addFiles ( [ pac_dir ] , prj )
for pac in prj . pacs_broken :
if prj . get_state ( pac ) != ' D ' :
prj . set_state ( pac , ' D ' )
print statfrmt ( ' D ' , getTransActPath ( os . path . join ( prj . dir , pac ) ) )
if opts . recursive :
for pac in prj . pacs_have :
state = prj . get_state ( pac )
if state != None and state != ' D ' :
pac_dir = getTransActPath ( os . path . join ( prj . dir , pac ) )
args . append ( pac_dir )
args . remove ( arg )
prj . write_packages ( )
2009-03-16 22:29:42 +01:00
elif is_project_dir ( arg ) :
print >> sys . stderr , ' osc: addremove is not supported in a project dir unless ' \
' \' do_package_tracking \' is enabled in the configuration file '
sys . exit ( 1 )
2008-08-20 21:24:55 +02:00
2007-04-25 01:00:12 +02:00
pacs = findpacs ( args )
for p in pacs :
p . todo = p . filenamelist + p . filenamelist_unvers
for filename in p . todo :
if os . path . isdir ( filename ) :
continue
2007-07-06 13:20:30 +02:00
# ignore foo.rXX, foo.mine for files which are in 'C' state
if os . path . splitext ( filename ) [ 0 ] in p . in_conflict :
2009-10-20 16:30:15 +02:00
continue
2007-04-25 01:00:12 +02:00
state = p . status ( filename )
2009-08-20 21:28:05 +02:00
2007-04-25 01:00:12 +02:00
if state == ' ? ' :
2009-08-20 21:28:05 +02:00
# TODO: should ignore typical backup files suffix ~ or .orig
2007-04-25 01:00:12 +02:00
p . addfile ( filename )
2008-08-20 21:24:55 +02:00
print statfrmt ( ' A ' , getTransActPath ( os . path . join ( p . dir , filename ) ) )
2007-04-25 01:00:12 +02:00
elif state == ' ! ' :
p . put_on_deletelist ( filename )
p . write_deletelist ( )
os . unlink ( os . path . join ( p . storedir , filename ) )
2008-08-20 21:24:55 +02:00
print statfrmt ( ' D ' , getTransActPath ( os . path . join ( p . dir , filename ) ) )
2007-04-25 01:00:12 +02:00
@cmdln.alias ( ' ci ' )
@cmdln.alias ( ' checkin ' )
2007-07-12 01:24:26 +02:00
@cmdln.option ( ' -m ' , ' --message ' , metavar = ' TEXT ' ,
help = ' specify log message TEXT ' )
2007-07-13 12:02:35 +02:00
@cmdln.option ( ' -F ' , ' --file ' , metavar = ' FILE ' ,
help = ' read log message from FILE ' )
2009-08-03 15:03:24 +02:00
@cmdln.option ( ' -f ' , ' --force ' , default = False , action = " store_true " ,
help = ' force commit - do not tests a file list ' )
2007-04-25 01:00:12 +02:00
def do_commit ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Upload content to the repository server
Upload content which is changed in your working copy , to the repository
server .
2009-08-05 07:54:12 +02:00
Optionally checks the state of a working copy , if found a file with
unknown state , it requests an user input :
2009-08-03 15:03:24 +02:00
* skip - don ' t change anything, just move to another file
* remove - remove a file from dir
* edit file list - edit filelist using EDITOR
* commit - don ' t check anything and commit package
* abort - abort commit - this is default value
2009-08-05 07:54:12 +02:00
This can be supressed by check_filelist config item , or - f / - - force
command line option .
2009-08-03 15:03:24 +02:00
2009-05-18 16:50:43 +02:00
examples :
2007-04-25 01:00:12 +02:00
osc ci # current dir
osc ci < dir >
osc ci file1 file2 . . .
$ { cmd_usage }
$ { cmd_option_list }
"""
2008-05-21 15:44:49 +02:00
args = parseargs ( args )
2008-03-10 19:04:23 +01:00
msg = ' '
if opts . message :
msg = opts . message
elif opts . file :
try :
msg = open ( opts . file ) . read ( )
except :
sys . exit ( ' could not open file \' %s \' . ' % opts . file )
2007-04-25 01:00:12 +02:00
2008-08-20 21:24:55 +02:00
arg_list = args [ : ]
for arg in arg_list :
2008-03-10 19:04:23 +01:00
if conf . config [ ' do_package_tracking ' ] and is_project_dir ( arg ) :
Project ( arg ) . commit ( msg = msg )
2009-08-19 13:28:10 +02:00
if not msg :
msg = edit_message ( )
2008-03-10 19:04:23 +01:00
args . remove ( arg )
2007-04-25 01:00:12 +02:00
2008-03-10 19:04:23 +01:00
pacs = findpacs ( args )
2008-05-21 15:44:49 +02:00
2009-08-04 16:12:45 +02:00
if conf . config [ ' check_filelist ' ] and not opts . force :
2009-08-03 15:03:24 +02:00
check_filelist_before_commit ( pacs )
2009-07-31 13:32:34 +02:00
2008-05-21 15:44:49 +02:00
if not msg :
2010-02-11 11:25:56 +01:00
template = store_read_file ( os . path . abspath ( ' . ' ) , ' _commit_msg ' )
2008-05-21 15:44:49 +02:00
# open editor for commit message
# but first, produce status and diff to append to the template
footer = diffs = [ ]
2010-02-11 11:25:56 +01:00
lines = [ ]
2008-05-21 15:44:49 +02:00
for pac in pacs :
changed = getStatus ( [ pac ] , quiet = True )
if changed :
footer + = changed
diffs + = [ ' \n Diff for working copy: %s ' % pac . dir ]
diffs + = make_diff ( pac , 0 )
2010-02-11 11:25:56 +01:00
lines . extend ( get_commit_message_template ( pac ) )
if template == None :
template = ' \n ' . join ( lines )
2008-05-21 15:44:49 +02:00
# if footer is empty, there is nothing to commit, and no edit needed.
if footer :
2010-02-11 11:25:56 +01:00
msg = edit_message ( footer = ' \n ' . join ( footer ) , template = template )
if msg :
store_write_string ( os . path . abspath ( ' . ' ) , ' _commit_msg ' , msg )
else :
store_unlink_file ( os . path . abspath ( ' . ' ) , ' _commit_msg ' )
2008-05-21 15:44:49 +02:00
2008-03-10 19:04:23 +01:00
if conf . config [ ' do_package_tracking ' ] and len ( pacs ) > 0 :
prj_paths = { }
single_paths = [ ]
files = { }
# it is possible to commit packages from different projects at the same
# time: iterate over all pacs and put each pac to the right project in the dict
for pac in pacs :
path = os . path . normpath ( os . path . join ( pac . dir , os . pardir ) )
if is_project_dir ( path ) :
pac_path = os . path . basename ( os . path . normpath ( pac . absdir ) )
prj_paths . setdefault ( path , [ ] ) . append ( pac_path )
files [ pac_path ] = pac . todo
else :
single_paths . append ( pac . dir )
for prj , packages in prj_paths . iteritems ( ) :
Project ( prj ) . commit ( tuple ( packages ) , msg , files )
for pac in single_paths :
Package ( pac ) . commit ( msg )
else :
for p in pacs :
p . commit ( msg )
2006-05-11 09:27:50 +02:00
2010-02-11 11:25:56 +01:00
store_unlink_file ( os . path . abspath ( ' . ' ) , ' _commit_msg ' )
2006-04-20 16:26:50 +02:00
2008-03-24 21:24:49 +01:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' REV ' ,
2007-07-04 14:55:26 +02:00
help = ' update to specified revision (this option will be ignored '
' if you are going to update the complete project or more than '
' one package) ' )
2008-03-24 21:24:49 +01:00
@cmdln.option ( ' -u ' , ' --unexpand-link ' , action = ' store_true ' ,
help = ' if a package is an expanded link, update to the raw _link file ' )
@cmdln.option ( ' -e ' , ' --expand-link ' , action = ' store_true ' ,
help = ' if a package is a link, update to the expanded sources ' )
2009-09-03 16:56:48 +02:00
@cmdln.option ( ' -s ' , ' --source-service-files ' , action = ' store_true ' ,
help = ' Use server side generated sources instead of local generation. ' )
2007-04-25 01:00:12 +02:00
@cmdln.alias ( ' up ' )
def do_update ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Update a working copy
2006-04-20 16:26:50 +02:00
2009-05-18 16:50:43 +02:00
examples :
2006-04-20 16:26:50 +02:00
2007-04-25 01:00:12 +02:00
1. osc up
If the current working directory is a package , update it .
If the directory is a project directory , update all contained
packages , AND check out newly added packages .
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
To update only checked out packages , without checking out new
ones , you might want to use " osc up * " from within the project
dir .
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
2. osc up PAC
Update the packages specified by the path argument ( s )
2006-04-20 16:26:50 +02:00
2008-03-24 21:24:49 +01:00
When - - expand - link is used with source link packages , the expanded
sources will be checked out . Without this option , the _link file and
patches will be checked out . The option - - unexpand - link can be used to
switch back to the " raw " source with a _link file plus patch ( es ) .
2007-04-25 01:00:12 +02:00
$ { cmd_usage }
$ { cmd_option_list }
"""
2006-04-20 16:26:50 +02:00
2009-08-12 01:01:03 +02:00
if ( opts . expand_link and opts . unexpand_link ) \
or ( opts . expand_link and opts . revision ) \
or ( opts . unexpand_link and opts . revision ) :
raise oscerr . WrongOptions ( ' Sorry, the options --expand-link, --unexpand-link and '
' --revision are mutually exclusive. ' )
2009-09-03 16:56:48 +02:00
if opts . source_service_files : service_files = True
else : service_files = False
2007-04-25 01:00:12 +02:00
args = parseargs ( args )
2008-08-20 21:24:55 +02:00
arg_list = args [ : ]
2006-04-24 14:04:20 +02:00
2008-08-20 21:24:55 +02:00
for arg in arg_list :
2007-04-25 01:00:12 +02:00
if is_project_dir ( arg ) :
2010-02-09 20:57:10 +01:00
prj = Project ( arg , progress_obj = self . download_progress )
2006-04-20 16:26:50 +02:00
2008-03-10 19:04:23 +01:00
if conf . config [ ' do_package_tracking ' ] :
2009-05-18 16:50:43 +02:00
prj . update ( expand_link = opts . expand_link ,
2008-03-24 21:24:49 +01:00
unexpand_link = opts . unexpand_link )
2008-03-10 19:04:23 +01:00
args . remove ( arg )
2009-05-18 16:50:43 +02:00
else :
# if not tracking package, and 'update' is run inside a project dir,
2008-03-10 19:04:23 +01:00
# it should do the following:
# (a) update all packages
args + = prj . pacs_have
# (b) fetch new packages
2010-01-21 14:47:04 +01:00
prj . checkout_missing_pacs ( expand_link = not opts . unexpand_link )
2008-03-10 19:04:23 +01:00
args . remove ( arg )
2009-09-18 03:10:41 +02:00
print_request_list ( prj . apiurl , prj . name )
2006-06-06 12:50:40 +02:00
2009-06-09 11:34:25 +02:00
args . sort ( )
2010-02-09 20:57:10 +01:00
pacs = findpacs ( args , progress_obj = self . download_progress )
2006-04-20 16:26:50 +02:00
2010-02-09 00:08:21 +01:00
if opts . revision and len ( args ) == 1 :
2007-07-04 14:55:26 +02:00
rev , dummy = parseRevisionOption ( opts . revision )
2008-02-18 14:44:20 +01:00
if not checkRevision ( pacs [ 0 ] . prjname , pacs [ 0 ] . name , rev , pacs [ 0 ] . apiurl ) :
2007-07-06 13:54:34 +02:00
print >> sys . stderr , ' Revision \' %s \' does not exist ' % rev
sys . exit ( 1 )
2007-07-04 14:55:26 +02:00
else :
rev = None
2007-04-25 01:00:12 +02:00
for p in pacs :
if len ( pacs ) > 1 :
print ' Updating %s ' % p . name
2008-03-24 21:24:49 +01:00
2010-01-20 17:55:44 +01:00
# FIXME: ugly workaround for #399247
if opts . expand_link or opts . unexpand_link :
if [ i for i in p . filenamelist + p . filenamelist_unvers if p . status ( i ) != ' ' and p . status ( i ) != ' ? ' ] :
print >> sys . stderr , ' osc: cannot expand/unexpand because your working ' \
' copy has local modifications. \n Please revert/commit them ' \
' and try again. '
sys . exit ( 1 )
2009-04-06 22:08:14 +02:00
2008-11-19 13:13:18 +01:00
if not rev :
if opts . expand_link and p . islink ( ) and not p . isexpanded ( ) :
2010-01-20 17:55:44 +01:00
if p . haslinkerror ( ) :
try :
rev = show_upstream_xsrcmd5 ( p . apiurl , p . prjname , p . name , revision = p . rev )
except :
rev = show_upstream_xsrcmd5 ( p . apiurl , p . prjname , p . name , revision = p . rev , linkrev = " base " )
p . mark_frozen ( )
else :
rev = p . linkinfo . xsrcmd5
print ' Expanding to rev ' , rev
2008-11-19 13:13:18 +01:00
elif opts . unexpand_link and p . islink ( ) and p . isexpanded ( ) :
print ' Unexpanding to rev ' , p . linkinfo . lsrcmd5
rev = p . linkinfo . lsrcmd5
elif p . islink ( ) and p . isexpanded ( ) :
2009-04-21 18:52:26 +02:00
rev = p . latest_rev ( )
2008-03-24 21:24:49 +01:00
2009-09-03 16:56:48 +02:00
p . update ( rev , service_files )
2010-01-20 17:55:44 +01:00
if opts . unexpand_link :
p . unmark_frozen ( )
2008-06-11 10:29:27 +02:00
rev = None
2009-09-18 03:10:41 +02:00
print_request_list ( p . apiurl , p . prjname , p . name )
2009-05-18 16:50:43 +02:00
2006-05-22 12:50:37 +02:00
2008-03-10 19:04:23 +01:00
@cmdln.option ( ' -f ' , ' --force ' , action = ' store_true ' ,
2009-05-04 21:07:05 +02:00
help = ' forces removal of entire package and its files ' )
2007-04-25 01:00:12 +02:00
@cmdln.alias ( ' rm ' )
@cmdln.alias ( ' del ' )
@cmdln.alias ( ' remove ' )
def do_delete ( self , subcmd , opts , * args ) :
2009-10-08 16:21:43 +02:00
""" $ {cmd_name} : Mark files or package directories to be deleted upon the next ' checkin '
2006-05-22 12:50:37 +02:00
2009-05-18 16:50:43 +02:00
usage :
2009-10-08 16:21:43 +02:00
cd . . . / PROJECT / PACKAGE
osc delete FILE [ . . . ]
cd . . . / PROJECT
osc delete PACKAGE [ . . . ]
2009-05-04 21:07:05 +02:00
This command works on check out copies . Use " rdelete " for working on server
side only . This is needed for removing the entire project .
2009-10-08 16:21:43 +02:00
As a safety measure , projects must be empty ( i . e . , you need to delete all
2009-10-20 16:30:15 +02:00
packages first ) .
2009-10-08 16:21:43 +02:00
If you are sure that you want to remove a package and all
its files use \' --force \' switch. Sometimes this also works without --force.
2009-05-04 21:07:05 +02:00
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2006-05-22 12:50:37 +02:00
2007-04-25 01:00:12 +02:00
if not args :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Missing argument. \n \n ' \
+ self . get_cmd_help ( ' delete ' ) )
2006-06-26 17:11:22 +02:00
2007-04-25 01:00:12 +02:00
args = parseargs ( args )
2008-03-10 19:04:23 +01:00
# check if args contains a package which was removed by
# a non-osc command and mark it with the 'D'-state
2008-08-20 21:24:55 +02:00
arg_list = args [ : ]
for i in arg_list :
2008-03-10 19:04:23 +01:00
if not os . path . exists ( i ) :
prj_dir , pac_dir = getPrjPacPaths ( i )
if is_project_dir ( prj_dir ) :
prj = Project ( prj_dir , False )
if i in prj . pacs_broken :
if prj . get_state ( i ) != ' A ' :
prj . set_state ( pac_dir , ' D ' )
else :
prj . del_package_node ( i )
print statfrmt ( ' D ' , getTransActPath ( i ) )
args . remove ( i )
prj . write_packages ( )
2007-04-25 01:00:12 +02:00
pacs = findpacs ( args )
2006-04-20 16:26:50 +02:00
2007-04-25 01:00:12 +02:00
for p in pacs :
2008-03-10 19:04:23 +01:00
if not p . todo :
prj_dir , pac_dir = getPrjPacPaths ( p . absdir )
2009-05-04 21:07:05 +02:00
if is_project_dir ( prj_dir ) :
2009-10-20 16:30:15 +02:00
if conf . config [ ' do_package_tracking ' ] :
prj = Project ( prj_dir , False )
prj . delPackage ( p , opts . force )
else :
print " WARNING: package tracking is disabled, operation skipped ! "
2008-03-10 19:04:23 +01:00
else :
pathn = getTransActPath ( p . dir )
for filename in p . todo :
2009-07-15 23:10:38 +02:00
ret , state = p . delete_file ( filename , opts . force )
if ret :
print statfrmt ( ' D ' , os . path . join ( pathn , filename ) )
continue
if state == ' ? ' :
2008-03-10 19:04:23 +01:00
sys . exit ( ' \' %s \' is not under version control ' % filename )
2009-07-15 23:10:38 +02:00
elif state in [ ' A ' , ' M ' ] and not opts . force :
sys . exit ( ' \' %s \' has local modifications (use --force to remove this file) ' % filename )
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
def do_resolved ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Remove ' conflicted ' state on working copy files
2009-05-18 16:50:43 +02:00
2007-04-25 01:00:12 +02:00
If an upstream change can ' t be merged automatically, a file is put into
in ' conflicted ' ( ' C ' ) state . Within the file , conflicts are marked with
special << << << < as well as == == == == and >> >> >> > lines .
2009-05-18 16:50:43 +02:00
2007-04-25 01:00:12 +02:00
After manually resolving all conflicting parts , use this command to
remove the ' conflicted ' state .
Note : this subcommand does not semantically resolve conflicts or
remove conflict markers ; it merely removes the conflict - related
artifact files and allows PATH to be committed again .
2006-05-23 15:48:58 +02:00
2009-05-18 16:50:43 +02:00
usage :
2007-04-25 01:00:12 +02:00
osc resolved FILE [ FILE . . . ]
$ { cmd_option_list }
"""
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
if not args :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Missing argument. \n \n ' \
+ self . get_cmd_help ( ' resolved ' ) )
2006-04-20 16:26:50 +02:00
2007-04-25 01:00:12 +02:00
args = parseargs ( args )
pacs = findpacs ( args )
2006-04-28 17:37:25 +02:00
2007-04-25 01:00:12 +02:00
for p in pacs :
for filename in p . todo :
print ' Resolved conflicted state of " %s " ' % filename
p . clear_from_conflictlist ( filename )
2006-04-20 16:26:50 +02:00
2009-09-08 10:14:27 +02:00
@cmdln.alias ( ' platforms ' )
def do_repositories ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Shows available repositories
2009-05-18 16:50:43 +02:00
2007-04-25 01:00:12 +02:00
Examples :
2009-09-08 10:14:27 +02:00
1. osc repositories
Shows all available repositories / build targets
2006-04-20 16:26:50 +02:00
2009-09-08 10:14:27 +02:00
2. osc repositories < project >
Shows the configured repositories / build targets of a project
2006-05-11 09:27:50 +02:00
2007-04-25 01:00:12 +02:00
$ { cmd_usage }
$ { cmd_option_list }
"""
2006-04-20 16:26:50 +02:00
2007-04-25 01:00:12 +02:00
if args :
project = args [ 0 ]
2009-09-08 10:14:27 +02:00
print ' \n ' . join ( get_repositories_of_project ( conf . config [ ' apiurl ' ] , project ) )
2007-04-25 01:00:12 +02:00
else :
2009-09-08 10:14:27 +02:00
print ' \n ' . join ( get_repositories ( conf . config [ ' apiurl ' ] ) )
2006-04-25 14:25:53 +02:00
2006-04-20 16:26:50 +02:00
2009-05-15 11:24:53 +02:00
@cmdln.hide ( 1 )
2007-05-04 23:51:54 +02:00
def do_results_meta ( self , subcmd , opts , * args ) :
2009-05-25 13:33:04 +02:00
print " Command results_meta is obsolete. Please use: osc results --xml "
2009-05-15 11:24:53 +02:00
sys . exit ( 1 )
2006-05-22 16:12:06 +02:00
2009-05-25 13:33:04 +02:00
@cmdln.hide ( 1 )
2009-08-20 21:28:05 +02:00
@cmdln.option ( ' -l ' , ' --last-build ' , action = ' store_true ' ,
help = ' show last build results (succeeded/failed/unknown) ' )
@cmdln.option ( ' -r ' , ' --repo ' , action = ' append ' , default = [ ] ,
help = ' Show results only for specified repo(s) ' )
@cmdln.option ( ' -a ' , ' --arch ' , action = ' append ' , default = [ ] ,
help = ' Show results only for specified architecture(s) ' )
@cmdln.option ( ' ' , ' --xml ' , action = ' store_true ' ,
help = ' generate output in XML (former results_meta) ' )
2009-05-25 13:33:04 +02:00
def do_rresults ( self , subcmd , opts , * args ) :
2009-08-20 21:28:05 +02:00
print " Command rresults is obsolete. Running ' osc results ' instead "
self . do_results ( ' results ' , opts , * args )
2009-05-25 13:33:04 +02:00
sys . exit ( 1 )
2009-05-18 16:50:43 +02:00
2009-07-07 16:30:15 +02:00
@cmdln.option ( ' -f ' , ' --force ' , action = ' store_true ' , default = False ,
help = " Don ' t ask and delete files " )
def do_rremove ( self , subcmd , opts , project , package , * files ) :
""" $ {cmd_name} : Remove source files from selected package
$ { cmd_usage }
$ { cmd_option_list }
"""
if len ( files ) == 0 :
if not ' / ' in project :
raise oscerr . WrongArgs ( " Missing operand, type osc help rremove for help " )
else :
files = ( package , )
project , package = project . split ( ' / ' )
for file in files :
if not opts . force :
2009-12-25 00:39:13 +01:00
resp = raw_input ( " rm: remove source file ` %s ' from ` %s / %s ' ? (yY|nN) " % ( file , project , package ) )
2009-07-07 16:30:15 +02:00
if resp not in ( ' y ' , ' Y ' ) :
continue
try :
delete_files ( conf . config [ ' apiurl ' ] , project , package , ( file , ) )
except urllib2 . HTTPError , e :
if opts . force :
2009-12-25 00:39:13 +01:00
print >> sys . stderr , e
2009-07-07 16:30:15 +02:00
body = e . read ( )
if e . code in [ 400 , 403 , 404 , 500 ] :
if ' <summary> ' in body :
msg = body . split ( ' <summary> ' ) [ 1 ]
msg = msg . split ( ' </summary> ' ) [ 0 ]
print >> sys . stderr , msg
else :
raise e
2008-06-17 08:12:48 +02:00
@cmdln.alias ( ' r ' )
2009-02-23 13:25:56 +01:00
@cmdln.option ( ' -l ' , ' --last-build ' , action = ' store_true ' ,
help = ' show last build results (succeeded/failed/unknown) ' )
2009-05-15 10:48:32 +02:00
@cmdln.option ( ' -r ' , ' --repo ' , action = ' append ' , default = [ ] ,
2009-05-15 09:16:26 +02:00
help = ' Show results only for specified repo(s) ' )
2009-05-15 10:48:32 +02:00
@cmdln.option ( ' -a ' , ' --arch ' , action = ' append ' , default = [ ] ,
2009-05-15 09:16:26 +02:00
help = ' Show results only for specified architecture(s) ' )
2009-05-15 11:24:53 +02:00
@cmdln.option ( ' ' , ' --xml ' , action = ' store_true ' ,
help = ' generate output in XML (former results_meta) ' )
2007-04-25 01:00:12 +02:00
def do_results ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Shows the build results of a package
2006-04-20 16:26:50 +02:00
2009-05-25 12:41:16 +02:00
Usage :
2009-05-25 13:33:04 +02:00
osc results ( inside working copy )
osc results remote_project remote_package
2008-05-16 14:25:50 +02:00
$ { cmd_option_list }
"""
2009-05-25 13:33:04 +02:00
2009-05-10 22:29:34 +02:00
args = slash_split ( args )
2009-08-20 21:28:05 +02:00
2009-06-05 08:13:08 +02:00
apiurl = conf . config [ ' apiurl ' ]
2009-05-25 12:41:16 +02:00
if len ( args ) == 0 :
2009-05-25 13:33:04 +02:00
wd = os . curdir
2010-01-14 15:20:00 +01:00
if is_project_dir ( wd ) :
2010-01-15 10:29:07 +01:00
opts . csv = None
opts . arch = None
opts . repo = None
opts . hide_legend = None
opts . name_filter = None
opts . status_filter = None
2010-01-15 11:00:50 +01:00
opts . vertical = None
2010-02-27 20:11:15 +01:00
self . do_prjresults ( ' prjresults ' , opts , * args )
2010-01-14 20:25:14 +01:00
sys . exit ( 0 )
2010-01-14 15:20:00 +01:00
else :
2010-01-14 20:25:14 +01:00
project = store_read_project ( wd )
package = store_read_package ( wd )
apiurl = store_read_apiurl ( wd )
2009-05-25 12:41:16 +02:00
elif len ( args ) < 2 :
2009-05-25 13:33:04 +02:00
raise oscerr . WrongArgs ( ' Too few arguments (required none or two) ' )
2009-05-10 22:29:34 +02:00
elif len ( args ) > 2 :
2009-05-25 13:33:04 +02:00
raise oscerr . WrongArgs ( ' Too many arguments (required none or two) ' )
else :
project = args [ 0 ]
package = args [ 1 ]
2009-05-18 16:50:43 +02:00
2009-05-15 11:24:53 +02:00
if not opts . xml :
func = get_results
delim = ' \n '
else :
func = show_results_meta
delim = ' '
2008-05-16 14:25:50 +02:00
2009-05-25 13:33:04 +02:00
print delim . join ( func ( apiurl , project , package , opts . last_build , opts . repo , opts . arch ) )
2009-05-18 16:50:43 +02:00
2010-01-14 15:20:00 +01:00
# WARNING: this function is also called by do_results. You need to set a default there
# as well when adding a new option!
2008-05-15 20:09:24 +02:00
@cmdln.option ( ' -q ' , ' --hide-legend ' , action = ' store_true ' ,
help = ' hide the legend ' )
2008-03-13 12:13:22 +01:00
@cmdln.option ( ' -c ' , ' --csv ' , action = ' store_true ' ,
2008-02-12 13:45:06 +01:00
help = ' csv output ' )
2008-05-15 20:09:24 +02:00
@cmdln.option ( ' -s ' , ' --status-filter ' , metavar = ' STATUS ' ,
help = ' show only packages with buildstatus STATUS (see legend) ' )
@cmdln.option ( ' -n ' , ' --name-filter ' , metavar = ' EXPR ' ,
2008-08-19 21:37:08 +02:00
help = ' show only packages whose names match EXPR ' )
2009-10-15 16:24:12 +02:00
@cmdln.option ( ' -a ' , ' --arch ' , metavar = ' ARCH ' ,
help = ' show results only for specified architecture(s) ' )
@cmdln.option ( ' -r ' , ' --repo ' , metavar = ' REPO ' ,
help = ' show results only for specified repo(s) ' )
2010-01-11 16:36:21 +01:00
@cmdln.option ( ' -V ' , ' --vertical ' , action = ' store_true ' ,
help = ' list packages vertically instead horizontally ' )
2008-06-17 08:12:48 +02:00
@cmdln.alias ( ' pr ' )
2007-04-25 01:00:12 +02:00
def do_prjresults ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Shows project-wide build results
2009-05-18 16:50:43 +02:00
2009-05-25 13:33:04 +02:00
Usage :
osc prjresults ( inside working copy )
2010-01-11 16:36:21 +01:00
osc prjresults PROJECT
2008-08-19 21:37:08 +02:00
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2006-04-29 22:44:09 +02:00
2009-05-25 13:33:04 +02:00
if args :
2008-08-19 21:37:08 +02:00
apiurl = conf . config [ ' apiurl ' ]
2009-05-25 13:33:04 +02:00
if len ( args ) == 1 :
project = args [ 0 ]
2008-08-19 21:37:08 +02:00
else :
2010-01-11 16:36:21 +01:00
raise oscerr . WrongArgs ( ' Wrong number of arguments. ' )
2009-05-25 13:33:04 +02:00
else :
wd = os . curdir
2008-08-19 21:37:08 +02:00
project = store_read_project ( wd )
apiurl = store_read_apiurl ( wd )
2006-05-23 15:48:58 +02:00
2010-01-11 16:36:21 +01:00
print ' \n ' . join ( get_prj_results ( apiurl , project , hide_legend = opts . hide_legend , csv = opts . csv , status_filter = opts . status_filter , name_filter = opts . name_filter , repo = opts . repo , arch = opts . arch , vertical = opts . vertical ) )
2007-04-25 01:00:12 +02:00
2008-05-16 14:25:50 +02:00
@cmdln.option ( ' -q ' , ' --hide-legend ' , action = ' store_true ' ,
help = ' hide the legend ' )
@cmdln.option ( ' -c ' , ' --csv ' , action = ' store_true ' ,
help = ' csv output ' )
@cmdln.option ( ' -s ' , ' --status-filter ' , metavar = ' STATUS ' ,
help = ' show only packages with buildstatus STATUS (see legend) ' )
@cmdln.option ( ' -n ' , ' --name-filter ' , metavar = ' EXPR ' ,
2008-08-19 21:37:08 +02:00
help = ' show only packages whose names match EXPR ' )
2008-05-16 14:25:50 +02:00
2009-05-25 13:33:04 +02:00
@cmdln.hide ( 1 )
def do_rprjresults ( self , subcmd , opts , * args ) :
print " Command rprjresults is obsolete. Please use ' osc prjresults ' "
sys . exit ( 1 )
2009-05-18 16:50:43 +02:00
2007-07-12 01:24:26 +02:00
@cmdln.alias ( ' bl ' )
2009-05-14 13:09:26 +02:00
@cmdln.option ( ' -s ' , ' --start ' , metavar = ' START ' ,
help = ' get log starting from the offset ' )
2009-11-23 11:13:19 +01:00
def do_buildlog ( self , subcmd , opts , * args ) :
2007-04-25 01:00:12 +02:00
""" $ {cmd_name} : Shows the build log of a package
Shows the log file of the build of a package . Can be used to follow the
log while it is being written .
Needs to be called from within a package directory .
2006-05-23 15:48:58 +02:00
2009-09-08 10:14:27 +02:00
The arguments REPOSITORY and ARCH are the first two columns in the ' osc
2010-02-16 13:49:14 +01:00
results ' output. If the buildlog url is used buildlog command has the
same behavior as remotebuildlog .
2007-04-25 01:00:12 +02:00
2010-02-16 13:49:14 +01:00
$ { cmd_usage } [ REPOSITORY ARCH | BUILDLOGURL ]
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2010-02-16 13:49:14 +01:00
repository = arch = None
if len ( args ) == 1 and args [ 0 ] . startswith ( ' http ' ) :
apiurl , project , package , repository , arch = parse_buildlogurl ( args [ 0 ] )
else :
wd = os . curdir
package = store_read_package ( wd )
project = store_read_project ( wd )
apiurl = store_read_apiurl ( wd )
2007-03-13 00:21:34 +01:00
2009-05-14 13:09:26 +02:00
offset = 0
if opts . start :
offset = int ( opts . start )
2010-02-16 13:49:14 +01:00
if not repository or not arch :
if len ( args ) < 2 :
self . print_repos ( )
else :
repository = args [ 0 ]
arch = args [ 1 ]
2009-11-23 11:13:19 +01:00
2009-09-08 10:14:27 +02:00
print_buildlog ( apiurl , project , package , repository , arch , offset )
2008-01-03 23:10:16 +01:00
2009-11-23 11:13:19 +01:00
def print_repos ( self ) :
2010-02-27 20:11:15 +01:00
wd = os . curdir
doprint = False
if is_package_dir ( wd ) :
str = " package "
doprint = True
elif is_project_dir ( wd ) :
str = " project "
doprint = True
if doprint :
print ' Valid arguments for this %s are: ' % str
print
self . do_repos ( None , None )
print
raise oscerr . WrongArgs ( ' Missing arguments ' )
2009-11-23 11:13:19 +01:00
2008-01-03 23:10:16 +01:00
@cmdln.alias ( ' rbl ' )
2009-05-21 14:05:39 +02:00
@cmdln.alias ( ' rbuildlog ' )
2010-01-28 13:20:11 +01:00
@cmdln.option ( ' -s ' , ' --start ' , metavar = ' START ' ,
help = ' get log starting from the offset ' )
2008-01-03 23:10:16 +01:00
def do_remotebuildlog ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Shows the build log of a package
Shows the log file of the build of a package . Can be used to follow the
log while it is being written .
usage :
2009-09-08 10:14:27 +02:00
osc remotebuildlog project package repository arch
2008-01-03 23:10:16 +01:00
or
2009-09-08 10:14:27 +02:00
osc remotebuildlog project / package / repository / arch
2010-02-16 12:23:25 +01:00
or
osc remotebuildlog buildlogurl
2008-01-03 23:10:16 +01:00
$ { cmd_option_list }
"""
2010-01-28 20:00:34 +01:00
if len ( args ) == 1 and args [ 0 ] . startswith ( ' http ' ) :
2010-01-28 13:20:11 +01:00
apiurl , project , package , repository , arch = parse_buildlogurl ( args [ 0 ] )
else :
args = slash_split ( args )
apiurl = conf . config [ ' apiurl ' ]
if len ( args ) < 4 :
raise oscerr . WrongArgs ( ' Too few arguments. ' )
elif len ( args ) > 4 :
raise oscerr . WrongArgs ( ' Too many arguments. ' )
else :
project , package , repository , arch = args
2010-02-28 02:30:13 +01:00
2010-01-28 13:20:11 +01:00
offset = 0
if opts . start :
offset = int ( opts . start )
2008-01-03 23:10:16 +01:00
2010-01-28 13:20:11 +01:00
print_buildlog ( apiurl , project , package , repository , arch , offset )
2006-05-23 15:48:58 +02:00
2010-02-12 15:54:33 +01:00
@cmdln.alias ( ' lbl ' )
@cmdln.option ( ' -s ' , ' --start ' , metavar = ' START ' ,
help = ' get log starting from offset ' )
2010-02-23 13:41:10 +01:00
def do_localbuildlog ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Shows the build log of a local buildchroot
2010-02-18 14:20:40 +01:00
2010-02-23 13:41:10 +01:00
usage :
osc lbl [ REPOSITORY ARCH ]
osc lbl # show log of newest last local build
2010-02-18 14:20:40 +01:00
$ { cmd_option_list }
"""
2010-02-12 15:54:33 +01:00
if conf . config [ ' build-type ' ] :
2010-02-23 13:41:10 +01:00
# FIXME: raise Exception instead
2010-02-12 15:54:33 +01:00
print >> sys . stderr , ' Not implemented for VMs '
sys . exit ( 1 )
2010-02-23 13:41:10 +01:00
if len ( args ) == 0 :
package = store_read_package ( ' . ' )
import glob
files = glob . glob ( os . path . join ( os . getcwd ( ) , store , " _buildinfo-* " ) )
if not files :
self . print_repos ( )
raise oscerr . WrongArgs ( ' No buildconfig found, please specify repo and arch manually. ' )
cfg = files [ 0 ]
# find newest file
for f in files [ 1 : ] :
if os . stat ( f ) . st_mtime > os . stat ( cfg ) . st_mtime :
cfg = f
root = ET . parse ( cfg ) . getroot ( )
project = root . get ( " project " )
repo = root . get ( " repository " )
arch = root . find ( " arch " ) . text
elif len ( args ) == 2 :
project = store_read_project ( ' . ' )
package = store_read_package ( ' . ' )
repo = args [ 0 ]
arch = args [ 1 ]
else :
if is_package_dir ( os . curdir ) :
self . print_repos ( )
raise oscerr . WrongArgs ( ' Wrong number of arguments. ' )
2010-02-12 15:54:33 +01:00
buildroot = os . environ . get ( ' OSC_BUILD_ROOT ' , conf . config [ ' build-root ' ] )
2010-02-23 13:41:10 +01:00
buildroot = buildroot % { ' project ' : project , ' package ' : package ,
2010-02-18 14:20:40 +01:00
' repo ' : repo , ' arch ' : arch }
2010-02-12 15:54:33 +01:00
offset = 0
if opts . start :
offset = int ( opts . start )
logfile = os . path . join ( buildroot , ' .build.log ' )
if not os . path . isfile ( logfile ) :
raise oscerr . OscIOError ( None , ' logfile \' %s \' does not exist ' % logfile )
f = open ( logfile , ' r ' )
f . seek ( offset )
data = f . read ( BUFSIZE )
while len ( data ) :
sys . stdout . write ( data )
data = f . read ( BUFSIZE )
f . close ( )
2006-09-25 17:11:03 +02:00
2009-12-09 07:53:33 +01:00
@cmdln.alias ( ' tr ' )
def do_triggerreason ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Show reason why a package got triggered to build
The server decides when a package needs to get rebuild , this command
shows the detailed reason for a package . A brief reason is also stored
in the jobhistory , which can be accessed via " osc jobhistory " .
Trigger reasons might be :
- new build ( never build yet or rebuild manually forced )
- source change ( eg . on updating sources )
- meta change ( packages which are used for building have changed )
- rebuild count sync ( In case that it is configured to sync release numbers )
usage in package or project directory :
osc reason REPOSITORY ARCH
osc reason PROJECT PACKAGE REPOSITORY ARCH
$ { cmd_option_list }
"""
wd = os . curdir
args = slash_split ( args )
project = package = repository = arch = None
2010-02-28 02:30:13 +01:00
2010-02-09 00:08:21 +01:00
if len ( args ) < 2 :
2009-12-09 07:53:33 +01:00
self . print_repos ( )
if len ( args ) == 2 : # 2
if is_package_dir ( ' . ' ) :
2010-02-27 20:11:15 +01:00
package = store_read_package ( wd )
2009-12-09 07:53:33 +01:00
else :
2010-02-27 20:11:15 +01:00
raise oscerr . WrongArgs ( ' package is not specified. ' )
2009-12-09 07:53:33 +01:00
project = store_read_project ( wd )
apiurl = store_read_apiurl ( wd )
repository = args [ 0 ]
arch = args [ 1 ]
elif len ( args ) == 4 :
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
package = args [ 1 ]
repository = args [ 2 ]
arch = args [ 3 ]
else :
raise oscerr . WrongArgs ( ' Too many arguments. ' )
print apiurl , project , package , repository , arch
xml = show_package_trigger_reason ( apiurl , project , package , repository , arch )
2009-12-26 14:22:34 +01:00
root = ET . fromstring ( xml )
reason = root . find ( ' explain ' ) . text
2009-12-09 07:53:33 +01:00
print reason
if reason == " meta change " :
2010-02-27 20:11:15 +01:00
print " changed keys: "
for package in root . findall ( ' packagechange ' ) :
print " " , package . get ( ' change ' ) , package . get ( ' key ' )
2009-12-09 07:53:33 +01:00
2009-12-04 16:20:17 +01:00
# FIXME: the new osc syntax should allow to specify multiple packages
# FIXME: the command should optionally use buildinfo data to show all dependencies
@cmdln.alias ( ' whatdependson ' )
def do_dependson ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Show the build dependencies
The command dependson and whatdependson can be used to find out what
will be triggered when a certain package changes .
This is no guarantee , since the new build might have changed dependencies .
2010-02-28 02:30:13 +01:00
dependson shows the build dependencies inside of a project , valid for a
2009-12-04 16:20:17 +01:00
given repository and architecture .
2010-02-28 02:30:13 +01:00
NOTE : to see all binary packages , which can trigger a build you need to
2009-12-04 16:20:17 +01:00
refer the buildinfo , since this command shows only the dependencies
inside of a project .
The arguments REPOSITORY and ARCH can be taken from the first two columns
of the ' osc repos ' output .
usage in package or project directory :
osc dependson REPOSITORY ARCH
osc whatdependson REPOSITORY ARCH
usage :
osc dependson PROJECT [ PACKAGE ] REPOSITORY ARCH
osc whatdependson PROJECT [ PACKAGE ] REPOSITORY ARCH
$ { cmd_option_list }
"""
wd = os . curdir
args = slash_split ( args )
project = packages = repository = arch = reverse = None
2010-02-28 02:30:13 +01:00
2010-02-09 00:08:21 +01:00
if len ( args ) < 2 and ( is_package_dir ( ' . ' ) or is_project_dir ( ' . ' ) ) :
2009-12-04 16:20:17 +01:00
self . print_repos ( )
if len ( args ) > 5 :
raise oscerr . WrongArgs ( ' Too many arguments. ' )
if len ( args ) < 3 : # 2
if is_package_dir ( ' . ' ) :
2010-02-27 20:11:15 +01:00
packages = [ store_read_package ( wd ) ]
2009-12-04 16:20:17 +01:00
elif not is_project_dir ( ' . ' ) :
2010-02-27 20:11:15 +01:00
raise oscerr . WrongArgs ( ' Project and package is not specified. ' )
2009-12-04 16:20:17 +01:00
project = store_read_project ( wd )
apiurl = store_read_apiurl ( wd )
repository = args [ 0 ]
arch = args [ 1 ]
if len ( args ) == 3 :
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
repository = args [ 1 ]
arch = args [ 2 ]
if len ( args ) == 4 :
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
packages = [ args [ 1 ] ]
repository = args [ 2 ]
arch = args [ 3 ]
if subcmd == ' whatdependson ' :
reverse = 1
xml = get_dependson ( apiurl , project , repository , arch , packages , reverse )
2009-12-26 14:22:34 +01:00
root = ET . fromstring ( xml )
for package in root . findall ( ' package ' ) :
2009-12-04 16:20:17 +01:00
print package . get ( ' name ' ) , " : "
for dep in package . findall ( ' pkgdep ' ) :
2010-02-27 20:11:15 +01:00
print " " , dep . text
2009-12-04 16:20:17 +01:00
2007-05-09 11:36:55 +02:00
@cmdln.option ( ' -x ' , ' --extra-pkgs ' , metavar = ' PAC ' , action = ' append ' ,
help = ' Add this package when computing the buildinfo ' )
2007-04-25 01:00:12 +02:00
def do_buildinfo ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Shows the build info
Shows the build " info " which is used in building a package .
This command is mostly used internally by the ' build ' subcommand .
It needs to be called from within a package directory .
The BUILD_DESCR argument is optional . BUILD_DESCR is a local RPM specfile
or Debian " dsc " file . If specified , it is sent to the server , and the
buildinfo will be based on it . If the argument is not supplied , the
buildinfo is derived from the specfile which is currently on the source
repository server .
The returned data is XML and contains a list of the packages used in
building , their source , and the expanded BuildRequires .
2009-09-08 10:14:27 +02:00
The arguments REPOSITORY and ARCH can be taken from the first two columns
2007-04-25 01:00:12 +02:00
of the ' osc repos ' output .
2009-05-18 16:50:43 +02:00
usage :
2009-11-06 20:52:28 +01:00
osc buildinfo REPOSITORY ARCH [ BUILD_DESCR ] ( in pkg dir )
osc buildinfo PROJECT PACKAGE REPOSITORY ARCH [ BUILD_DESCR ]
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2006-09-25 17:11:03 +02:00
wd = os . curdir
2009-11-06 20:52:28 +01:00
args = slash_split ( args )
2010-02-28 02:30:13 +01:00
2010-02-09 00:08:21 +01:00
if len ( args ) < 2 and is_package_dir ( ' . ' ) :
2009-11-23 11:13:19 +01:00
self . print_repos ( )
2009-05-18 16:50:43 +02:00
2009-11-06 20:52:28 +01:00
if len ( args ) > 5 :
raise oscerr . WrongArgs ( ' Too many arguments. ' )
if len ( args ) < 4 : # 2 or 3
package = store_read_package ( wd )
project = store_read_project ( wd )
apiurl = store_read_apiurl ( wd )
repository = args [ 0 ]
arch = args [ 1 ]
if len ( args ) > 3 and len ( args ) < 6 : # 4 or 5
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
package = args [ 1 ]
repository = args [ 2 ]
arch = args [ 3 ]
# for following specfile detection ...
del args [ 0 ]
del args [ 0 ]
2007-04-25 01:00:12 +02:00
# were we given a specfile (third argument)?
try :
spec = open ( args [ 2 ] ) . read ( )
except IndexError :
spec = None
except IOError , e :
2007-04-25 23:10:49 +02:00
print >> sys . stderr , e
return 1
2007-04-25 01:00:12 +02:00
2009-05-18 16:50:43 +02:00
print ' ' . join ( get_buildinfo ( apiurl ,
2009-09-08 10:14:27 +02:00
project , package , repository , arch ,
2009-05-18 16:50:43 +02:00
specfile = spec ,
2007-05-09 11:36:55 +02:00
addlist = opts . extra_pkgs ) )
2007-04-25 01:00:12 +02:00
2006-09-25 17:11:03 +02:00
2009-11-06 20:52:28 +01:00
def do_buildconfig ( self , subcmd , opts , * args ) :
2007-04-25 01:00:12 +02:00
""" $ {cmd_name} : Shows the build config
Shows the build configuration which is used in building a package .
This command is mostly used internally by the ' build ' command .
It needs to be called from inside a package directory .
The returned data is the project - wide build configuration in a format
which is directly readable by the build script . It contains RPM macros
and BuildRequires expansions , for example .
2009-09-08 10:14:27 +02:00
The arguments REPOSITORY and ARCH can be taken from the first two columns
2009-06-16 15:31:11 +02:00
of the ' osc repos ' output .
2007-04-25 01:00:12 +02:00
2009-11-06 20:52:28 +01:00
usage :
osc buildconfig REPOSITORY ARCH ( in pkg dir )
osc buildconfig PROJECT PACKAGE REPOSITORY ARCH
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
wd = os . curdir
2009-11-06 20:52:28 +01:00
args = slash_split ( args )
2010-02-28 02:30:13 +01:00
2010-02-09 00:08:21 +01:00
if len ( args ) < 2 and is_package_dir ( ' . ' ) :
2009-11-23 11:13:19 +01:00
self . print_repos ( )
2009-11-06 20:52:28 +01:00
if len ( args ) > 4 :
raise oscerr . WrongArgs ( ' Too many arguments. ' )
if len ( args ) == 2 :
package = store_read_package ( wd )
project = store_read_project ( wd )
apiurl = store_read_apiurl ( wd )
repository = args [ 0 ]
arch = args [ 1 ]
elif len ( args ) == 4 :
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
package = args [ 1 ]
repository = args [ 2 ]
arch = args [ 3 ]
else :
raise oscerr . WrongArgs ( ' Wrong number of arguments. ' )
2006-09-25 17:11:03 +02:00
2009-09-08 10:14:27 +02:00
print ' ' . join ( get_buildconfig ( apiurl , project , package , repository , arch ) )
2006-09-25 17:11:03 +02:00
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
def do_repos ( self , subcmd , opts , * args ) :
2009-11-30 10:57:39 +01:00
""" $ {cmd_name} : shows repositories configured for a project
2006-06-22 13:26:01 +02:00
2009-11-30 10:57:39 +01:00
usage :
osc repos
osc repos [ PROJECT ]
2006-09-25 17:11:03 +02:00
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2006-09-15 13:47:34 +02:00
2009-11-30 10:57:39 +01:00
apiurl = conf . config [ ' apiurl ' ]
2006-09-15 13:47:34 +02:00
2009-11-30 10:57:39 +01:00
if len ( args ) == 1 :
project = args [ 0 ]
elif len ( args ) == 0 :
project = store_read_project ( ' . ' )
apiurl = store_read_apiurl ( ' . ' )
else :
raise oscerr . WrongArgs ( ' Wrong number of arguments ' )
2006-07-05 12:25:31 +02:00
2009-11-30 10:57:39 +01:00
data = [ ]
for repo in get_repos_of_project ( apiurl , project ) :
data + = [ repo . name , repo . arch ]
for row in build_table ( 2 , data , width = 2 ) :
print row
2006-07-05 12:25:31 +02:00
2010-01-30 16:18:30 +01:00
def parse_repoarchdescr ( self , args , noinit = False , alternative_project = None ) :
""" helper to parse the repo, arch and build description from args """
import osc . build
arg_arch = arg_repository = arg_descr = None
if len ( args ) < 3 :
for arg in args :
if arg . endswith ( ' .spec ' ) or arg . endswith ( ' .dsc ' ) or arg . endswith ( ' .kiwi ' ) :
arg_descr = arg
else :
if arg in osc . build . can_also_build . get ( osc . build . hostarch , [ ] ) or \
arg in osc . build . hostarch :
arg_arch = arg
elif not arg_repository :
arg_repository = arg
else :
raise oscerr . WrongArgs ( ' unexpected argument: \' %s \' ' % arg )
else :
arg_repository , arg_arch , arg_descr = args
arg_arch = arg_arch or osc . build . hostarch
if not noinit :
project = alternative_project or store_read_project ( ' . ' )
repositories = get_repositories_of_project ( store_read_apiurl ( ' . ' ) , project )
if not len ( repositories ) :
raise oscerr . WrongArgs ( ' no repositories defined for project \' %s \' ' % project )
if not arg_repository :
# Use a default value from config, but just even if it's available
# unless try standard, or openSUSE_Factory
arg_repository = repositories [ - 1 ]
for repository in ( conf . config [ ' build_repository ' ] , ' standard ' , ' openSUSE_Factory ' ) :
if repository in repositories :
arg_repository = repository
break
if not arg_repository in repositories :
raise oscerr . WrongArgs ( ' %s is not a valid repository, use one of: %s ' % ( arg_repository , ' , ' . join ( repositories ) ) )
elif not arg_repository :
raise oscerr . WrongArgs ( ' please specify a repository ' )
descr = [ i for i in os . listdir ( ' . ' ) if i . endswith ( ' .spec ' ) or i . endswith ( ' .dsc ' ) or i . endswith ( ' .kiwi ' ) ]
# FIXME:
# * request repos from server and select by build type.
if not arg_descr and len ( descr ) == 1 :
arg_descr = descr [ 0 ]
elif not arg_descr :
msg = ' Missing argument: build description (spec, dsc or kiwi file) '
try :
p = Package ( ' . ' )
if p . islink ( ) and not p . isexpanded ( ) :
msg + = ' (this package is not expanded - you might want to try osc up --expand) '
except :
pass
raise oscerr . WrongArgs ( msg )
return arg_repository , arg_arch , arg_descr
2007-04-25 01:00:12 +02:00
@cmdln.option ( ' --clean ' , action = ' store_true ' ,
help = ' Delete old build root before initializing it ' )
2007-09-03 12:25:18 +02:00
@cmdln.option ( ' --no-changelog ' , action = ' store_true ' ,
help = ' don \' t update the package changelog from a changes file ' )
2009-10-20 16:30:15 +02:00
@cmdln.option ( ' --rsync-src ' , metavar = ' RSYNCSRCPATH ' , dest = ' rsyncsrc ' ,
2009-08-18 23:28:33 +02:00
help = ' Copy folder to buildroot after installing all RPMs. Use together with --rsync-dest. This is the path on the HOST filesystem e.g. /tmp/linux-kernel-tree. It defines RSYNCDONE 1 . ' )
2009-10-20 16:30:15 +02:00
@cmdln.option ( ' --rsync-dest ' , metavar = ' RSYNCDESTPATH ' , dest = ' rsyncdest ' ,
2009-08-18 23:28:33 +02:00
help = ' Copy folder to buildroot after installing all RPMs. Use together with --rsync-src. This is the path on the TARGET filesystem e.g. /usr/src/packages/BUILD/linux-2.6 . ' )
@cmdln.option ( ' --overlay ' , metavar = ' OVERLAY ' ,
help = ' Copy overlay filesystem to buildroot after installing all RPMs . ' )
2007-04-25 01:00:12 +02:00
@cmdln.option ( ' --noinit ' , ' --no-init ' , action = ' store_true ' ,
help = ' Skip initialization of build root and start with build immediately. ' )
2008-07-23 22:05:09 +02:00
@cmdln.option ( ' --nochecks ' , ' --no-checks ' , action = ' store_true ' ,
help = ' Do not run post build checks on the resulting packages. ' )
2008-01-24 19:06:45 +01:00
@cmdln.option ( ' --no-verify ' , action = ' store_true ' ,
help = ' Skip signature verification of packages used for build. ' )
2010-02-05 10:32:27 +01:00
@cmdln.option ( ' --noservice ' , ' --no-service ' , action = ' store_true ' ,
help = ' Skip run of local source services as specified in _service file. ' )
2007-05-03 17:54:40 +02:00
@cmdln.option ( ' -p ' , ' --prefer-pkgs ' , metavar = ' DIR ' , action = ' append ' ,
2007-05-02 15:49:57 +02:00
help = ' Prefer packages from this directory when installing the build-root ' )
2009-05-18 16:50:43 +02:00
@cmdln.option ( ' -k ' , ' --keep-pkgs ' , metavar = ' DIR ' ,
2007-05-03 17:54:40 +02:00
help = ' Save built packages into this directory ' )
2007-05-09 11:36:55 +02:00
@cmdln.option ( ' -x ' , ' --extra-pkgs ' , metavar = ' PAC ' , action = ' append ' ,
help = ' Add this package when installing the build-root ' )
2009-11-23 14:53:59 +01:00
@cmdln.option ( ' --root ' , metavar = ' ROOT ' ,
help = ' Build in specified directory ' )
2008-04-24 11:00:23 +02:00
@cmdln.option ( ' -j ' , ' --jobs ' , metavar = ' N ' ,
help = ' Compile with N jobs ' )
2008-12-11 12:36:07 +01:00
@cmdln.option ( ' --icecream ' , metavar = ' N ' ,
help = ' use N parallel build jobs with icecream ' )
@cmdln.option ( ' --ccache ' , action = ' store_true ' ,
help = ' use ccache to speed up rebuilds ' )
2009-11-24 10:49:26 +01:00
@cmdln.option ( ' --with ' , metavar = ' X ' , dest = ' _with ' , action = ' append ' ,
2008-12-11 12:36:07 +01:00
help = ' enable feature X for build ' )
2009-11-24 10:49:26 +01:00
@cmdln.option ( ' --without ' , metavar = ' X ' , action = ' append ' ,
2008-12-11 12:36:07 +01:00
help = ' disable feature X for build ' )
# will not work as build.py does not support proper quoting
2009-11-24 10:49:26 +01:00
# @cmdln.option('--define', metavar='\'X Y\'', action='append',
2008-12-11 12:36:07 +01:00
# help='define macro X with value Y')
2007-05-14 10:29:50 +02:00
@cmdln.option ( ' --userootforbuild ' , action = ' store_true ' ,
help = ' Run build as root. The default is to build as '
' unprivileged user. Note that a line " # norootforbuild " '
' in the spec file will invalidate this option. ' )
2010-02-12 22:54:39 +01:00
@cmdln.option ( ' --build-uid ' , metavar = ' uid:gid| " caller " ' ,
help = ' specify the numeric uid:gid pair to assign to the '
' unprivileged " abuild " user or use " caller " to use the current user uid:gid ' )
2009-03-31 13:45:30 +02:00
@cmdln.option ( ' --local-package ' , action = ' store_true ' ,
2008-01-07 15:54:31 +01:00
help = ' build a package which does not exist on the server ' )
2009-12-09 06:53:27 +01:00
@cmdln.option ( ' --linksources ' , action = ' store_true ' ,
help = ' use hard links instead of a deep copied source ' )
2009-03-31 13:45:30 +02:00
@cmdln.option ( ' --alternative-project ' , metavar = ' PROJECT ' ,
2008-01-07 15:54:31 +01:00
help = ' specify the build target project ' )
2008-03-11 16:18:02 +01:00
@cmdln.option ( ' -d ' , ' --debuginfo ' , action = ' store_true ' ,
help = ' also build debuginfo sub-packages ' )
2009-03-31 13:45:30 +02:00
@cmdln.option ( ' --disable-debuginfo ' , action = ' store_true ' ,
help = ' disable build of debuginfo packages ' )
2008-05-08 14:21:57 +02:00
@cmdln.option ( ' -b ' , ' --baselibs ' , action = ' store_true ' ,
help = ' Create -32bit/-64bit/-x86 rpms for other architectures ' )
2009-12-01 14:36:11 +01:00
@cmdln.option ( ' --release ' , metavar = ' N ' ,
help = ' set release number of the package to N ' )
2010-01-20 09:15:17 +01:00
@cmdln.option ( ' --cpio-bulk-download ' , action = ' store_true ' ,
help = ' enable downloading packages as cpio archive from api ' )
@cmdln.option ( ' --download-api-only ' , action = ' store_true ' ,
help = SUPPRESS_HELP )
2007-04-25 01:00:12 +02:00
def do_build ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Build a package on your local machine
2006-09-15 13:47:34 +02:00
2007-04-25 01:00:12 +02:00
You need to call the command inside a package directory , which should be a
buildsystem checkout . ( Local modifications are fine . )
2006-07-05 12:25:31 +02:00
2009-09-08 10:14:27 +02:00
The arguments REPOSITORY and ARCH can be taken from the first two columns
2007-04-25 01:00:12 +02:00
of the ' osc repos ' output . BUILD_DESCR is either a RPM spec file , or a
Debian dsc file .
2006-07-05 12:25:31 +02:00
2010-02-12 22:54:39 +01:00
The command honours packagecachedir , build - root and build - uid
settings in . oscrc , if present . You may want to set su - wrapper = ' sudo '
in . oscrc , and configure sudo with option NOPASSWD for / usr / bin / build .
2006-07-05 12:25:31 +02:00
2007-05-02 15:49:57 +02:00
If neither - - clean nor - - noinit is given , build will reuse an existing
build - root again , removing unneeded packages and add missing ones . This
is usually the fastest option .
2006-07-05 12:25:31 +02:00
2008-01-07 15:54:31 +01:00
If the package doesn ' t exist on the server please use the --local-package
option .
If the project of the package doesn ' t exist on the server please use the
- - alternative - project < alternative - project > option :
Example :
osc build [ OPTS ] - - alternative - project openSUSE : 10.3 standard i586 BUILD_DESCR
2009-05-18 16:50:43 +02:00
usage :
2009-09-08 10:14:27 +02:00
osc build [ OPTS ] REPOSITORY ARCH BUILD_DESCR
osc build [ OPTS ] REPOSITORY ( ARCH = hostarch , BUILD_DESCR is detected automatically )
osc build [ OPTS ] ARCH ( REPOSITORY = build_repository ( config option ) , BUILD_DESCR is detected automatically )
osc build [ OPTS ] BUILD_DESCR ( REPOSITORY = build_repository ( config option ) , ARCH = hostarch )
osc build [ OPTS ] ( REPOSITORY = build_repository ( config option ) , ARCH = hostarch , BUILD_DESCR is detected automatically )
2008-04-09 20:45:59 +02:00
2009-05-18 16:50:43 +02:00
# Note:
# Configuration can be overridden by envvars, e.g.
# OSC_SU_WRAPPER overrides the setting of su-wrapper.
2008-04-09 20:45:59 +02:00
# OSC_BUILD_ROOT overrides the setting of build-root.
# OSC_PACKAGECACHEDIR overrides the setting of packagecachedir.
$ { cmd_option_list }
"""
2006-07-14 19:39:46 +02:00
2007-04-25 01:00:12 +02:00
import osc . build
2006-07-14 19:45:44 +02:00
2007-09-03 16:52:45 +02:00
if not os . path . exists ( ' /usr/lib/build/debtransform ' ) \
and not os . path . exists ( ' /usr/lib/lbuild/debtransform ' ) :
2007-07-19 12:49:30 +02:00
sys . stderr . write ( ' Error: you need build.rpm with version 2007.3.12 or newer. \n ' )
2007-07-16 11:45:17 +02:00
sys . stderr . write ( ' See http://download.opensuse.org/repositories/openSUSE:/Tools/ \n ' )
2007-04-25 01:00:12 +02:00
return 1
2006-07-17 15:15:42 +02:00
2009-03-31 13:45:30 +02:00
if opts . debuginfo and opts . disable_debuginfo :
raise oscerr . WrongOptions ( ' osc: --debuginfo and --disable-debuginfo are mutual exclusive ' )
2008-07-30 18:45:00 +02:00
if len ( args ) > 3 :
raise oscerr . WrongArgs ( ' Too many arguments ' )
2009-05-18 16:50:43 +02:00
2010-01-30 16:18:30 +01:00
args = self . parse_repoarchdescr ( args , opts . noinit , opts . alternative_project )
2009-11-26 10:52:26 +01:00
2009-09-03 16:56:48 +02:00
# check for source services
2010-02-05 10:32:27 +01:00
if not opts . noservice and not opts . noinit and os . listdir ( ' . ' ) . count ( " _service " ) :
2009-09-03 16:56:48 +02:00
p = Package ( ' . ' )
p . run_source_services ( )
2007-05-03 17:54:40 +02:00
if opts . prefer_pkgs :
for d in opts . prefer_pkgs :
2007-05-02 15:49:57 +02:00
if not os . path . isdir ( d ) :
2010-01-09 14:25:41 +01:00
raise oscerr . WrongOptions ( ' Preferred package location \' %s \' is not a directory ' % d )
2007-05-02 15:49:57 +02:00
2010-01-09 14:25:41 +01:00
if opts . keep_pkgs and not os . path . isdir ( opts . keep_pkgs ) :
raise oscerr . WrongOptions ( ' Preferred save location \' %s \' is not a directory ' % opts . keep_pkgs )
2009-05-18 16:50:43 +02:00
2010-01-30 16:18:30 +01:00
print ' Building %s for %s / %s ' % ( args [ 2 ] , args [ 0 ] , args [ 1 ] )
2007-05-02 15:49:57 +02:00
return osc . build . main ( opts , args )
2006-07-14 19:39:46 +02:00
2009-05-18 16:50:43 +02:00
2010-01-30 16:18:30 +01:00
@cmdln.option ( ' --local-package ' , action = ' store_true ' ,
help = ' package doesn \' t exist on the server ' )
@cmdln.option ( ' --alternative-project ' , metavar = ' PROJECT ' ,
help = ' specify the used build target project ' )
@cmdln.option ( ' --noinit ' , ' --no-init ' , action = ' store_true ' ,
help = ' do not guess/verify specified repository ' )
@cmdln.option ( ' -r ' , ' --root ' , action = ' store_true ' ,
help = ' login as root instead of abuild ' )
def do_chroot ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : chroot into the buildchroot
chroot into the buildchroot for the given repository , arch and build description
( NOTE : this command does not work if " build-type " is set in the config )
usage :
osc chroot [ OPTS ] REPOSITORY ARCH BUILD_DESCR
osc chroot [ OPTS ] REPOSITORY ( ARCH = hostarch , BUILD_DESCR is detected automatically )
osc chroot [ OPTS ] ARCH ( REPOSITORY = build_repository ( config option ) , BUILD_DESCR is detected automatically )
osc chroot [ OPTS ] BUILD_DESCR ( REPOSITORY = build_repository ( config option ) , ARCH = hostarch )
osc chroot [ OPTS ] ( REPOSITORY = build_repository ( config option ) , ARCH = hostarch , BUILD_DESCR is detected automatically )
$ { cmd_option_list }
"""
if len ( args ) > 3 :
raise oscerr . WrongArgs ( ' Too many arguments ' )
if conf . config [ ' build-type ' ] :
print >> sys . stderr , ' Not implemented for VMs '
sys . exit ( 1 )
user = ' abuild '
if opts . root :
2010-04-08 23:15:55 +02:00
user = ' root '
2010-01-30 16:18:30 +01:00
repository , arch , descr = self . parse_repoarchdescr ( args , opts . noinit , opts . alternative_project )
project = opts . alternative_project or store_read_project ( ' . ' )
if opts . local_package :
package = os . path . splitext ( descr ) [ 0 ]
else :
package = store_read_package ( ' . ' )
buildroot = os . environ . get ( ' OSC_BUILD_ROOT ' , conf . config [ ' build-root ' ] ) \
% { ' repo ' : repository , ' arch ' : arch , ' project ' : project , ' package ' : package }
if not os . path . isdir ( buildroot ) :
raise oscerr . OscIOError ( None , ' \' %s \' is not a directory ' % buildroot )
2010-01-30 21:41:49 +01:00
suwrapper = os . environ . get ( ' OSC_SU_WRAPPER ' , conf . config [ ' su-wrapper ' ] )
sucmd = suwrapper . split ( ) [ 0 ]
suargs = ' ' . join ( suwrapper . split ( ) [ 1 : ] )
if suwrapper . startswith ( ' su ' ) :
cmd = [ sucmd , ' %s chroot " %s " su - %s ' % ( suargs , buildroot , user ) ]
else :
cmd = [ sucmd , ' chroot ' , buildroot , ' su ' , ' - ' , user ]
if suargs :
cmd . insert ( 1 , suargs )
print ' running: %s ' % ' ' . join ( cmd )
os . execvp ( sucmd , cmd )
2010-01-30 16:18:30 +01:00
2006-07-14 19:39:46 +02:00
2009-05-13 11:04:27 +02:00
@cmdln.option ( ' ' , ' --csv ' , action = ' store_true ' ,
help = ' generate output in CSV (separated by |) ' )
2007-04-25 01:00:12 +02:00
@cmdln.alias ( ' buildhist ' )
2009-09-08 10:14:27 +02:00
def do_buildhistory ( self , subcmd , opts , * args ) :
2007-04-25 01:00:12 +02:00
""" $ {cmd_name} : Shows the build history of a package
2006-05-19 22:13:29 +02:00
2009-09-08 10:14:27 +02:00
The arguments REPOSITORY and ARCH can be taken from the first two columns
2007-04-25 01:00:12 +02:00
of the ' osc repos ' output .
2009-09-08 10:14:27 +02:00
usage :
osc buildhist REPOSITORY ARCHITECTURE
osc buildhist PROJECT PACKAGE REPOSITORY ARCHITECTURE
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2006-05-23 15:48:58 +02:00
2010-02-09 00:08:21 +01:00
if len ( args ) < 2 and is_package_dir ( ' . ' ) :
2009-11-23 11:13:19 +01:00
self . print_repos ( )
2009-09-08 10:14:27 +02:00
if len ( args ) == 4 :
2009-10-20 16:30:15 +02:00
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
package = args [ 1 ]
repository = args [ 2 ]
arch = args [ 3 ]
2009-09-08 10:14:27 +02:00
elif len ( args ) == 2 :
2009-10-20 16:30:15 +02:00
wd = os . curdir
package = store_read_package ( wd )
project = store_read_project ( wd )
repository = args [ 0 ]
arch = args [ 1 ]
apiurl = store_read_apiurl ( wd )
2009-09-08 10:14:27 +02:00
else :
2009-10-20 16:30:15 +02:00
raise oscerr . WrongArgs ( ' Wrong number of arguments ' )
2006-09-29 12:37:53 +02:00
2009-05-13 11:04:27 +02:00
format = ' text '
if opts . csv :
format = ' csv '
2009-09-08 10:14:27 +02:00
print ' \n ' . join ( get_buildhistory ( apiurl , project , package , repository , arch , format ) )
2006-06-08 12:30:29 +02:00
2009-05-13 11:04:27 +02:00
@cmdln.option ( ' ' , ' --csv ' , action = ' store_true ' ,
help = ' generate output in CSV (separated by |) ' )
2009-11-13 14:31:10 +01:00
@cmdln.option ( ' -l ' , ' --limit ' , metavar = ' limit ' ,
help = ' for setting the number of results ' )
2009-02-20 12:04:45 +01:00
@cmdln.alias ( ' jobhist ' )
2009-11-06 19:47:54 +01:00
def do_jobhistory ( self , subcmd , opts , * args ) :
2009-02-20 12:04:45 +01:00
""" $ {cmd_name} : Shows the job history of a project
2009-09-08 10:14:27 +02:00
The arguments REPOSITORY and ARCH can be taken from the first two columns
2009-02-20 12:04:45 +01:00
of the ' osc repos ' output .
2009-11-06 19:47:54 +01:00
usage :
osc jobhist REPOSITORY ARCHITECTURE ( in project dir )
osc jobhist PROJECT [ PACKAGE ] REPOSITORY ARCHITECTURE
2009-02-20 12:04:45 +01:00
$ { cmd_option_list }
"""
wd = os . curdir
2009-11-06 19:47:54 +01:00
args = slash_split ( args )
2010-02-09 02:27:29 +01:00
if len ( args ) < 2 and ( is_project_dir ( ' . ' ) or is_package_dir ( ' . ' ) ) :
2009-11-23 11:13:19 +01:00
self . print_repos ( )
2009-11-06 19:47:54 +01:00
if len ( args ) == 4 :
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
package = args [ 1 ]
repository = args [ 2 ]
arch = args [ 3 ]
elif len ( args ) == 3 :
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
package = None # skipped = prj
repository = args [ 1 ]
arch = args [ 2 ]
elif len ( args ) == 2 :
package = None
try :
package = store_read_package ( wd )
except :
pass
project = store_read_project ( wd )
repository = args [ 0 ]
arch = args [ 1 ]
apiurl = store_read_apiurl ( wd )
else :
raise oscerr . WrongArgs ( ' Wrong number of arguments ' )
2009-02-20 12:04:45 +01:00
2009-05-13 11:04:27 +02:00
format = ' text '
if opts . csv :
format = ' csv '
2009-11-23 11:13:12 +01:00
print_jobhistory ( apiurl , project , package , repository , arch , format , opts . limit )
2009-02-20 12:04:45 +01:00
2009-05-25 13:33:04 +02:00
@cmdln.hide ( 1 )
def do_rlog ( self , subcmd , opts , * args ) :
print " Command rlog is obsolete. Please use ' osc log ' "
sys . exit ( 1 )
2006-10-10 16:04:34 +02:00
2010-01-14 11:58:34 +01:00
2007-07-12 02:48:52 +02:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' rev ' ,
help = ' show log of the specified revision ' )
2009-05-13 10:53:32 +02:00
@cmdln.option ( ' ' , ' --csv ' , action = ' store_true ' ,
help = ' generate output in CSV (separated by |) ' )
@cmdln.option ( ' ' , ' --xml ' , action = ' store_true ' ,
help = ' generate output in XML ' )
2009-05-25 13:33:04 +02:00
def do_log ( self , subcmd , opts , * args ) :
2007-07-12 01:24:26 +02:00
""" $ {cmd_name} : Shows the commit log of a package
2009-05-25 12:41:16 +02:00
Usage :
2009-05-25 13:33:04 +02:00
osc log ( inside working copy )
osc log remote_project remote_package
2009-05-25 12:41:16 +02:00
2008-09-23 15:39:54 +02:00
$ { cmd_option_list }
"""
2009-05-25 12:41:16 +02:00
args = slash_split ( args )
if len ( args ) == 0 :
2009-05-25 13:33:04 +02:00
wd = os . curdir
project = store_read_project ( wd )
package = store_read_package ( wd )
apiurl = store_read_apiurl ( wd )
2009-05-25 12:41:16 +02:00
elif len ( args ) < 2 :
2009-05-25 13:33:04 +02:00
raise oscerr . WrongArgs ( ' Too few arguments (required none or two) ' )
2009-05-25 12:41:16 +02:00
elif len ( args ) > 2 :
2009-05-25 13:33:04 +02:00
raise oscerr . WrongArgs ( ' Too many arguments (required none or two) ' )
else :
apiurl = conf . config [ ' apiurl ' ]
project = args [ 0 ]
package = args [ 1 ]
2009-05-25 12:41:16 +02:00
2008-09-23 15:39:54 +02:00
rev , dummy = parseRevisionOption ( opts . revision )
2009-05-25 13:33:04 +02:00
if rev and not checkRevision ( project , package , rev , apiurl ) :
2008-09-23 15:39:54 +02:00
print >> sys . stderr , ' Revision \' %s \' does not exist ' % rev
sys . exit ( 1 )
2009-05-13 10:53:32 +02:00
format = ' text '
if opts . csv :
format = ' csv '
if opts . xml :
format = ' xml '
2009-05-25 13:33:04 +02:00
print ' \n ' . join ( get_commitlog ( apiurl , project , package , rev , format ) )
2008-09-23 15:39:54 +02:00
2007-04-25 01:00:12 +02:00
@cmdln.option ( ' -f ' , ' --failed ' , action = ' store_true ' ,
help = ' rebuild all failed packages ' )
2009-06-15 17:38:39 +02:00
@cmdln.alias ( ' rebuildpac ' )
def do_rebuild ( self , subcmd , opts , * args ) :
2007-04-25 01:00:12 +02:00
""" $ {cmd_name} : Triggers package rebuilds
2006-10-10 16:04:34 +02:00
2007-04-25 01:00:12 +02:00
With the optional < repo > and < arch > arguments , the rebuild can be limited
to a certain repository or architecture .
2006-06-08 12:30:29 +02:00
2007-04-25 01:00:12 +02:00
Note that it is normally NOT needed to kick off rebuilds like this , because
they principally happen in a fully automatic way , triggered by source
check - ins . In particular , the order in which packages are built is handled
by the build service .
2006-09-25 17:11:03 +02:00
2007-04-25 01:00:12 +02:00
Note the - - failed option , which can be used to rebuild all failed
packages .
2006-09-25 17:11:03 +02:00
2009-09-08 10:14:27 +02:00
The arguments REPOSITORY and ARCH can be taken from the first two columns
2009-06-23 12:06:31 +02:00
of the ' osc repos ' output .
2006-06-08 12:30:29 +02:00
2009-05-18 16:50:43 +02:00
usage :
2009-09-08 10:14:27 +02:00
osc rebuild PROJECT [ PACKAGE [ REPOSITORY [ ARCH ] ] ]
2007-04-25 01:00:12 +02:00
$ { cmd_option_list }
"""
2006-06-08 12:30:29 +02:00
2007-06-26 15:17:38 +02:00
args = slash_split ( args )
2007-04-25 01:00:12 +02:00
if len ( args ) < 1 :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Missing argument. ' )
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
package = repo = arch = code = None
project = args [ 0 ]
if len ( args ) > 1 :
package = args [ 1 ]
if len ( args ) > 2 :
repo = args [ 2 ]
if len ( args ) > 3 :
arch = args [ 3 ]
2006-05-23 15:48:58 +02:00
2007-04-25 01:00:12 +02:00
if opts . failed :
code = ' failed '
2007-06-14 16:30:36 +02:00
print rebuild ( conf . config [ ' apiurl ' ] , project , package , repo , arch , code )
2006-05-23 15:48:58 +02:00
2006-04-20 16:26:50 +02:00
2007-05-04 23:51:54 +02:00
def do_info ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Print information about a working copy
Print information about each ARG ( default : ' . ' )
ARG is a working - copy path .
$ { cmd_usage }
$ { cmd_option_list }
"""
args = parseargs ( args )
pacs = findpacs ( args )
for p in pacs :
print p . info ( )
2006-05-19 22:13:29 +02:00
2007-06-14 16:30:36 +02:00
@cmdln.option ( ' -a ' , ' --arch ' , metavar = ' ARCH ' ,
help = ' Abort builds for a specific architecture ' )
@cmdln.option ( ' -r ' , ' --repo ' , metavar = ' REPO ' ,
help = ' Abort builds for a specific repository ' )
def do_abortbuild ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Aborts the build of a certain project/package
2009-05-18 16:50:43 +02:00
2007-06-14 16:30:36 +02:00
With the optional argument < package > you can specify a certain package
otherwise all builds in the project will be cancelled .
2009-05-18 16:50:43 +02:00
usage :
2007-06-14 16:30:36 +02:00
osc abortbuild [ OPTS ] PROJECT [ PACKAGE ]
$ { cmd_option_list }
"""
if len ( args ) < 1 :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Missing <project> argument. ' )
2007-06-14 16:30:36 +02:00
if len ( args ) == 2 :
package = args [ 1 ]
else :
package = None
print abortbuild ( conf . config [ ' apiurl ' ] , args [ 0 ] , package , opts . arch , opts . repo )
@cmdln.option ( ' -a ' , ' --arch ' , metavar = ' ARCH ' ,
2007-07-04 16:57:19 +02:00
help = ' Delete all binary packages for a specific architecture ' )
2007-06-14 16:30:36 +02:00
@cmdln.option ( ' -r ' , ' --repo ' , metavar = ' REPO ' ,
help = ' Delete all binary packages for a specific repository ' )
2007-07-04 16:57:19 +02:00
@cmdln.option ( ' --build-disabled ' , action = ' store_true ' ,
help = ' Delete all binaries of packages for which the build is disabled ' )
2007-10-27 21:13:24 +02:00
@cmdln.option ( ' --build-failed ' , action = ' store_true ' ,
help = ' Delete all binaries of packages for which the build failed ' )
@cmdln.option ( ' --broken ' , action = ' store_true ' ,
help = ' Delete all binaries of packages for which the package source is bad ' )
2009-01-10 23:55:25 +01:00
@cmdln.option ( ' --expansion ' , action = ' store_true ' ,
help = ' Delete all binaries of packages which have expansion errors ' )
2009-05-31 13:00:03 +02:00
@cmdln.option ( ' --all ' , action = ' store_true ' ,
help = ' Delete all binaries regardless of the package status (previously default) ' )
2007-06-14 16:30:36 +02:00
def do_wipebinaries ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Delete all binary packages of a certain project/package
2007-07-15 15:49:13 +02:00
With the optional argument < package > you can specify a certain package
2007-06-14 16:30:36 +02:00
otherwise all binary packages in the project will be deleted .
2009-05-18 16:50:43 +02:00
usage :
2009-05-31 13:00:03 +02:00
osc wipebinaries OPTS PROJECT [ PACKAGE ]
2007-06-14 16:30:36 +02:00
$ { cmd_option_list }
"""
2009-05-18 16:50:43 +02:00
2007-06-26 15:17:38 +02:00
args = slash_split ( args )
2007-06-14 16:30:36 +02:00
if len ( args ) < 1 :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Missing <project> argument. ' )
2008-06-11 10:01:10 +02:00
if len ( args ) > 2 :
raise oscerr . WrongArgs ( ' Wrong number of arguments. ' )
2007-06-14 16:30:36 +02:00
if len ( args ) == 2 :
package = args [ 1 ]
else :
package = None
2007-10-27 21:13:24 +02:00
codes = [ ]
if opts . build_disabled :
codes . append ( ' disabled ' )
if opts . build_failed :
codes . append ( ' failed ' )
if opts . broken :
codes . append ( ' broken ' )
2009-01-10 23:55:25 +01:00
if opts . expansion :
codes . append ( ' expansion error ' )
2009-07-07 16:31:59 +02:00
if opts . all or opts . repo or opts . arch :
2009-05-31 13:00:03 +02:00
codes . append ( None )
2007-10-27 21:13:24 +02:00
if len ( codes ) == 0 :
2010-01-09 14:25:41 +01:00
raise oscerr . WrongOptions ( ' No option has been provided. If you want to delete all binaries, use --all option. ' )
2007-10-27 21:13:24 +02:00
# make a new request for each code= parameter
for code in codes :
print wipebinaries ( conf . config [ ' apiurl ' ] , args [ 0 ] , package , opts . arch , opts . repo , code )
2007-06-14 16:30:36 +02:00
2008-09-30 16:54:08 +02:00
@cmdln.option ( ' -q ' , ' --quiet ' , action = ' store_true ' ,
help = ' do not show downloading progress ' )
@cmdln.option ( ' -d ' , ' --destdir ' , default = ' . ' , metavar = ' DIR ' ,
help = ' destination directory ' )
2009-01-16 11:31:38 +01:00
@cmdln.option ( ' --sources ' , action = " store_true " ,
help = ' also fetch source packages ' )
2009-04-21 11:46:32 +02:00
def do_getbinaries ( self , subcmd , opts , * args ) :
2008-09-30 16:54:08 +02:00
""" $ {cmd_name} : Download binaries to a local directory
2009-05-18 16:50:43 +02:00
This command downloads packages directly from the api server .
2009-02-20 16:01:16 +01:00
Thus , it directly accesses the packages that are used for building
others even when they are not " published " yet .
2008-09-30 16:54:08 +02:00
2009-04-21 11:46:32 +02:00
usage :
osc getbinaries REPOSITORY ARCHITECTURE # works in checked out package
osc getbinaries PROJECT PACKAGE REPOSITORY ARCHITECTURE
2008-09-30 16:54:08 +02:00
$ { cmd_option_list }
"""
2009-04-21 11:46:32 +02:00
args = slash_split ( args )
apiurl = conf . config [ ' apiurl ' ]
2010-02-09 00:08:21 +01:00
if len ( args ) < 2 and is_package_dir ( ' . ' ) :
2009-11-23 11:13:19 +01:00
self . print_repos ( )
2009-04-21 11:46:32 +02:00
if len ( args ) == 4 :
project = args [ 0 ]
package = args [ 1 ]
repository = args [ 2 ]
architecture = args [ 3 ]
elif len ( args ) == 2 :
if is_package_dir ( os . getcwd ( ) ) :
2009-12-21 23:47:25 +01:00
project = store_read_project ( os . curdir )
package = store_read_package ( os . curdir )
apiurl = store_read_apiurl ( os . curdir )
2009-10-20 16:30:15 +02:00
repository = args [ 0 ]
architecture = args [ 1 ]
2009-04-21 11:46:32 +02:00
else :
2009-10-20 16:30:15 +02:00
sys . exit ( ' Local directory is no checkout package, neither it is specified. ' )
2009-04-21 11:46:32 +02:00
else :
2009-11-20 15:35:57 +01:00
raise oscerr . WrongArgs ( ' Need either 2 or 4 arguments ' )
2009-04-21 11:46:32 +02:00
2008-09-30 16:54:08 +02:00
# Get package list
2009-05-18 16:50:43 +02:00
binaries = get_binarylist ( apiurl ,
project , repository , architecture ,
2008-09-30 16:54:08 +02:00
package = package , verbose = True )
if not os . path . isdir ( opts . destdir ) :
print " Creating %s " % opts . destdir
os . makedirs ( opts . destdir , 0755 )
if binaries == [ ] :
sys . exit ( ' no binaries found. Either the package does not '
2009-02-20 16:01:16 +01:00
' exist or no binaries have been built. ' )
2008-09-30 16:54:08 +02:00
for binary in binaries :
# skip source rpms
2009-01-16 11:31:38 +01:00
if not opts . sources and binary . name . endswith ( ' .src.rpm ' ) :
2008-09-30 16:54:08 +02:00
continue
target_filename = ' %s / %s ' % ( opts . destdir , binary . name )
if os . path . exists ( target_filename ) :
st = os . stat ( target_filename )
if st . st_mtime == binary . mtime and st . st_size == binary . size :
continue
2009-05-18 16:50:43 +02:00
get_binary_file ( apiurl ,
project ,
repository , architecture ,
binary . name ,
2008-09-30 16:54:08 +02:00
package = package ,
target_filename = target_filename ,
target_mtime = binary . mtime ,
progress_meter = not opts . quiet )
2010-01-12 15:10:32 +01:00
@cmdln.option ( ' -b ' , ' --bugowner ' , action = ' store_true ' ,
help = ' restrict listing to items where the user is bugowner ' )
@cmdln.option ( ' -m ' , ' --maintainer ' , action = ' store_true ' ,
help = ' restrict listing to items where the user is maintainer ' )
2009-08-21 03:26:37 +02:00
@cmdln.option ( ' -a ' , ' --all ' , action = ' store_true ' ,
2010-01-12 15:10:32 +01:00
help = ' all involvements ' )
@cmdln.option ( ' -U ' , ' --user ' , metavar = ' USER ' ,
help = ' search for USER instead of yourself ' )
2010-03-13 14:06:48 +01:00
@cmdln.option ( ' --exclude-project ' , action = ' append ' ,
2010-01-12 15:10:32 +01:00
help = ' exclude requests for specified project ' )
@cmdln.option ( ' -v ' , ' --verbose ' , action = ' store_true ' ,
help = ' verbose listing ' )
def do_my ( self , subcmd , opts , type ) :
""" $ {cmd_name} : show packages, projects or requests involving yourself
Examples :
# list packages where I am bugowner
osc $ { cmd_name } pkg - b
# list projects where I am maintainer
osc $ { cmd_name } prj - m
# list request for all my projects and packages
osc $ { cmd_name } rq
# list requests, excluding project 'foo' and 'bar'
osc $ { cmd_name } rq - - exclude - project foo , bar
# list submitrequests I made
osc $ { cmd_name } sr
$ { cmd_usage }
where TYPE is one of requests , submitrequests ,
projects or packages ( rq , sr , prj or pkg )
$ { cmd_option_list }
2009-09-03 20:08:43 +02:00
"""
2009-08-21 03:26:37 +02:00
2010-01-12 15:10:32 +01:00
args_rq = ( ' requests ' , ' request ' , ' req ' , ' rq ' )
args_sr = ( ' submitrequests ' , ' submitrequest ' , ' submitreq ' , ' submit ' , ' sr ' )
args_prj = ( ' projects ' , ' project ' , ' projs ' , ' proj ' , ' prj ' )
args_pkg = ( ' packages ' , ' package ' , ' pack ' , ' pkgs ' , ' pkg ' )
2010-03-13 14:06:48 +01:00
if opts . bugowner and opts . maintainer :
raise oscerr . WrongOptions ( ' Sorry, \' --bugowner \' and \' maintainer \' are mutually exclusive ' )
elif opts . all and ( opts . bugowner or opts . maintainer ) :
raise oscerr . WrongOptions ( ' Sorry, \' --all \' and \' --bugowner \' or \' --maintainer \' are mutually exclusive ' )
2009-08-21 03:26:37 +02:00
2010-03-13 14:06:48 +01:00
exclude_projects = [ ]
for i in opts . exclude_project or [ ] :
prj = i . split ( ' , ' )
if len ( prj ) == 1 :
exclude_projects . append ( i )
else :
exclude_projects . extend ( prj )
2010-01-12 15:10:32 +01:00
if not opts . user :
2010-03-13 14:06:48 +01:00
user = conf . get_apiurl_usr ( conf . config [ ' apiurl ' ] )
2010-01-12 15:10:32 +01:00
else :
user = opts . user
list_requests = False
2010-03-13 14:06:48 +01:00
what = { ' project ' : ' ' , ' package ' : ' ' }
2010-01-12 15:10:32 +01:00
if type in args_rq :
list_requests = True
elif type in args_prj :
2010-03-13 14:06:48 +01:00
what = { ' project ' : ' ' }
elif type in args_sr :
requests = get_request_list ( conf . config [ ' apiurl ' ] , req_who = user , exclude_target_projects = exclude_projects )
for r in requests :
print r . list_view ( )
return
elif not type in args_pkg :
2010-01-12 15:10:32 +01:00
raise oscerr . WrongArgs ( " invalid type %s " % type )
2010-03-13 14:06:48 +01:00
role_filter = ' '
if opts . maintainer :
2010-01-12 15:10:32 +01:00
role_filter = ' maintainer '
elif opts . bugowner :
role_filter = ' bugowner '
2010-03-13 14:06:48 +01:00
elif list_requests :
role_filter = ' maintainer '
if opts . all :
role_filter = ' '
2010-03-13 21:06:18 +01:00
res = get_user_projpkgs ( conf . config [ ' apiurl ' ] , user , role_filter ,
exclude_projects , what . has_key ( ' project ' ) , what . has_key ( ' package ' ) )
2010-03-13 14:06:48 +01:00
request_todo = { }
roles = { }
if len ( what . keys ( ) ) == 2 :
2010-03-17 17:32:59 +01:00
for i in res [ ' project_id ' ] . findall ( ' project ' ) :
2010-03-13 14:06:48 +01:00
request_todo [ i . get ( ' name ' ) ] = [ ]
roles [ i . get ( ' name ' ) ] = [ p . get ( ' role ' ) for p in i . findall ( ' person ' ) if p . get ( ' userid ' ) == user ]
2010-03-17 17:32:59 +01:00
for i in res [ ' package_id ' ] . findall ( ' package ' ) :
2010-03-13 14:06:48 +01:00
roles [ ' / ' . join ( [ i . get ( ' project ' ) , i . get ( ' name ' ) ] ) ] = [ p . get ( ' role ' ) for p in i . findall ( ' person ' ) if p . get ( ' userid ' ) == user ]
if not i . get ( ' project ' ) in request_todo . keys ( ) :
request_todo . setdefault ( i . get ( ' project ' ) , [ ] ) . append ( i . get ( ' name ' ) )
else :
2010-03-17 17:32:59 +01:00
for i in res [ ' project_id ' ] . findall ( ' project ' ) :
2010-03-13 14:06:48 +01:00
roles [ i . get ( ' name ' ) ] = [ p . get ( ' role ' ) for p in i . findall ( ' person ' ) if p . get ( ' userid ' ) == user ]
2010-01-12 15:10:32 +01:00
if list_requests :
2010-03-13 21:06:18 +01:00
requests = get_user_projpkgs_request_list ( conf . config [ ' apiurl ' ] , user , projpkgs = request_todo )
for r in requests :
2010-03-13 14:06:48 +01:00
print r . list_view ( )
2010-01-12 15:10:32 +01:00
else :
2010-03-13 14:06:48 +01:00
for i in sorted ( roles . keys ( ) ) :
out = ' %s ' % i
prjpac = i . split ( ' / ' )
if type in args_pkg and len ( prjpac ) == 1 and not opts . verbose :
continue
2010-01-12 15:10:32 +01:00
if opts . verbose :
2010-03-13 14:06:48 +01:00
out = ' %s ( %s ) ' % ( i , ' , ' . join ( sorted ( roles [ i ] ) ) )
if len ( prjpac ) == 2 :
out = ' %s ( %s ) ' % ( prjpac [ 1 ] , ' , ' . join ( sorted ( roles [ i ] ) ) )
print out
2009-08-21 03:26:37 +02:00
2008-09-30 16:54:08 +02:00
2007-08-09 13:35:08 +02:00
@cmdln.option ( ' --repos-baseurl ' , action = ' store_true ' ,
help = ' show base URLs of download repositories ' )
2009-04-07 20:45:42 +02:00
@cmdln.option ( ' -e ' , ' --exact ' , action = ' store_true ' ,
2009-11-23 17:13:57 +01:00
help = ' show only exact matches, this is default now ' )
@cmdln.option ( ' -s ' , ' --substring ' , action = ' store_true ' ,
help = ' Show also results where the search term is a sub string, slower search ' )
2007-07-15 15:49:13 +02:00
@cmdln.option ( ' --package ' , action = ' store_true ' ,
help = ' search for a package ' )
@cmdln.option ( ' --project ' , action = ' store_true ' ,
help = ' search for a project ' )
@cmdln.option ( ' --title ' , action = ' store_true ' ,
help = ' search for matches in the \' title \' element ' )
@cmdln.option ( ' --description ' , action = ' store_true ' ,
help = ' search for matches in the \' description \' element ' )
2009-10-22 12:10:15 +02:00
@cmdln.option ( ' -a ' , ' --limit-to-attribute ' , metavar = ' ATTRIBUTE ' ,
help = ' match only when given attribute exists in meta data ' )
2007-07-15 15:49:13 +02:00
@cmdln.option ( ' -v ' , ' --verbose ' , action = ' store_true ' ,
help = ' show more information ' )
2008-06-24 17:07:44 +02:00
@cmdln.option ( ' -i ' , ' --involved ' , action = ' store_true ' ,
2009-08-21 03:26:37 +02:00
help = ' show projects/packages where given person (or myself) is involved as bugowner or maintainer ' )
@cmdln.option ( ' -b ' , ' --bugowner ' , action = ' store_true ' ,
help = ' as -i, but only bugowner ' )
@cmdln.option ( ' -m ' , ' --maintainer ' , action = ' store_true ' ,
help = ' as -i, but only maintainer ' )
2009-11-06 17:08:20 +01:00
@cmdln.option ( ' --maintained ' , action = ' store_true ' ,
help = ' limit search results to packages with maintained attribute set. ' )
2009-08-21 03:26:37 +02:00
@cmdln.option ( ' -M ' , ' --mine ' , action = ' store_true ' ,
help = ' shorthand for --bugowner --package ' )
2009-05-15 10:33:25 +02:00
@cmdln.option ( ' --csv ' , action = ' store_true ' ,
help = ' generate output in CSV (separated by |) ' )
2010-03-15 16:08:00 +01:00
@cmdln.option ( ' --binary ' , action = ' store_true ' ,
help = ' search binary packages ' )
@cmdln.option ( ' -B ' , ' --baseproject ' , metavar = ' PROJECT ' ,
help = ' search packages built for PROJECT (implies --binary) ' )
2009-11-06 17:08:20 +01:00
@cmdln.alias ( ' sm ' )
2009-08-21 03:26:37 +02:00
@cmdln.alias ( ' se ' )
2010-03-20 12:27:27 +01:00
@cmdln.alias ( ' bse ' )
2010-03-10 23:36:09 +01:00
def do_search ( self , subcmd , opts , search_term ) :
2007-12-10 15:23:58 +01:00
""" $ {cmd_name} : Search for a project and/or package.
2007-07-15 15:49:13 +02:00
If no option is specified osc will search for projects and
packages which contains the \' search term \' in their name,
title or description .
usage :
osc search \' search term \' <options>
2010-03-20 12:27:27 +01:00
osc sm \' source package name \' ( ' osc search - - maintained ' )
osc bse . . . ( ' osc search --binary ' )
2009-09-03 20:08:43 +02:00
osc se . . .
2007-07-15 15:49:13 +02:00
$ { cmd_option_list }
"""
2010-03-10 23:36:09 +01:00
def build_xpath ( attr , what , substr = False ) :
if substr :
return ' contains( %s , \' %s \' ) ' % ( attr , what )
else :
return ' %s = \' %s \' ' % ( attr , what )
2009-09-03 20:08:43 +02:00
if opts . mine :
opts . bugowner = True
opts . package = True
2009-10-20 16:30:15 +02:00
2010-03-10 23:36:09 +01:00
if ( opts . title or opts . description ) and ( opts . involved or opts . bugowner or opts . maintainer ) :
raise oscerr . WrongOptions ( ' Sorry, the options \' --title \' and/or \' --description \' ' \
' are mutually exclusive with \' -i \' / \' -b \' / \' -m \' / \' -M \' ' )
if opts . substring and opts . exact :
raise oscerr . WrongOptions ( ' Sorry, the options \' --substring \' and \' --exact \' are mutually exclusive ' )
2007-07-15 15:49:13 +02:00
2009-11-06 17:08:20 +01:00
if subcmd == ' sm ' or opts . maintained :
2009-11-02 10:28:27 +01:00
opts . package = True
2009-11-23 17:13:57 +01:00
if not opts . substring :
opts . exact = True
2010-03-20 12:27:27 +01:00
if subcmd == ' bse ' or opts . baseproject :
2010-03-15 16:08:00 +01:00
opts . binary = True
if opts . binary and ( opts . title or opts . description or opts . involved or opts . bugowner or opts . maintainer
or opts . project or opts . package ) :
raise oscerr . WrongOptions ( ' Sorry, \' --binary \' and \' --title \' or \' --description \' or \' --involved ' \
' or \' --bugowner \' or \' --maintainer \' or \' --limit-to-attribute <attr> \ ' \
' or \' --project \' or \' --package \' are mutually exclusive ' )
2010-02-28 02:30:13 +01:00
2010-03-10 23:36:09 +01:00
xpath = ' '
if opts . title :
xpath = xpath_join ( xpath , build_xpath ( ' title ' , search_term , opts . substring ) , inner = True )
if opts . description :
xpath = xpath_join ( xpath , build_xpath ( ' description ' , search_term , opts . substring ) , inner = True )
2010-03-15 16:08:00 +01:00
if opts . project or opts . package or opts . binary :
2010-03-10 23:36:09 +01:00
xpath = xpath_join ( xpath , build_xpath ( ' @name ' , search_term , opts . substring ) , inner = True )
# role filter
role_filter = ' '
if opts . bugowner or opts . maintainer or opts . involved :
xpath = xpath_join ( xpath , ' person/@userid = \' %s \' ' % search_term , inner = True )
role_filter = ' %s ( %s ) ' % ( search_term , ' person ' )
2010-03-12 15:22:11 +01:00
role_filter_xpath = xpath
2010-03-10 23:36:09 +01:00
if opts . bugowner and not opts . maintainer :
xpath = xpath_join ( xpath , ' person/@role= \' bugowner \' ' , op = ' and ' )
2010-03-12 15:22:11 +01:00
role_filter = ' bugowner '
2010-03-10 23:36:09 +01:00
elif not opts . bugowner and opts . maintainer :
xpath = xpath_join ( xpath , ' person/@role= \' maintainer \' ' , op = ' and ' )
2010-03-12 15:22:11 +01:00
role_filter = ' maintainer '
2010-03-10 23:36:09 +01:00
if opts . limit_to_attribute :
xpath = xpath_join ( xpath , ' attribute/@name= \' %s \' ' % opts . limit_to_attribute , op = ' and ' )
2010-03-15 16:08:00 +01:00
if opts . baseproject :
xpath = xpath_join ( xpath , ' path/@project= \' %s \' ' % opts . baseproject , op = ' and ' )
2009-08-21 03:26:37 +02:00
2010-03-10 23:36:09 +01:00
if not xpath :
xpath = xpath_join ( xpath , build_xpath ( ' @name ' , search_term , opts . substring ) , inner = True )
xpath = xpath_join ( xpath , build_xpath ( ' title ' , search_term , opts . substring ) , inner = True )
xpath = xpath_join ( xpath , build_xpath ( ' description ' , search_term , opts . substring ) , inner = True )
what = { ' project ' : xpath , ' package ' : xpath }
if subcmd == ' sm ' or opts . maintained :
xpath = xpath_join ( xpath , ' (project/attribute/@name= \' %(attr)s \' or attribute/@name= \' %(attr)s \' ) ' % { ' attr ' : conf . config [ ' maintained_attribute ' ] } , op = ' and ' )
what = { ' package ' : xpath }
elif opts . project and not opts . package :
what = { ' project ' : xpath }
elif not opts . project and opts . package :
what = { ' package ' : xpath }
2010-03-18 17:57:25 +01:00
elif opts . binary :
2010-03-15 16:08:00 +01:00
what = { ' published/binary/id ' : xpath }
2010-03-12 15:22:11 +01:00
try :
res = search ( conf . config [ ' apiurl ' ] , * * what )
except urllib2 . HTTPError , e :
if e . code != 400 or not role_filter :
raise e
# backward compatibility: local role filtering
if opts . limit_to_attribute :
role_filter_xpath = xpath_join ( role_filter_xpath , ' attribute/@name= \' %s \' ' % opts . limit_to_attribute , op = ' and ' )
what = dict ( [ [ kind , role_filter_xpath ] for kind in what . keys ( ) ] )
res = search ( conf . config [ ' apiurl ' ] , * * what )
2010-03-13 14:06:48 +01:00
filter_role ( res , search_term , role_filter )
2010-03-12 15:22:11 +01:00
if role_filter :
role_filter = ' %s ( %s ) ' % ( search_term , role_filter )
2010-03-15 16:08:00 +01:00
kind_map = { ' published/binary/id ' : ' binary ' }
2010-03-10 23:36:09 +01:00
for kind , root in res . iteritems ( ) :
results = [ ]
2010-03-15 16:08:00 +01:00
for node in root . findall ( kind_map . get ( kind , kind ) ) :
2010-03-10 23:36:09 +01:00
result = [ ]
project = node . get ( ' project ' )
package = None
if project is None :
project = node . get ( ' name ' )
else :
package = node . get ( ' name ' )
result . append ( project )
if not package is None :
result . append ( package )
if opts . verbose :
title = node . findtext ( ' title ' ) . strip ( )
if len ( title ) > 60 :
title = title [ : 61 ] + ' ... '
result . append ( title )
if opts . repos_baseurl :
# FIXME: no hardcoded URL of instance
result . append ( ' http://download.opensuse.org/repositories/ %s / ' % project . replace ( ' : ' , ' :/ ' ) )
2010-03-15 16:08:00 +01:00
if kind == ' published/binary/id ' :
result . append ( node . get ( ' filepath ' ) )
2010-03-10 23:36:09 +01:00
results . append ( result )
if not len ( results ) :
2009-08-21 03:26:37 +02:00
print ' No matches found for \' %s \' in %s s ' % ( role_filter or search_term , kind )
2009-06-09 19:07:02 +02:00
continue
2010-03-10 23:36:09 +01:00
# construct a sorted, flat list
results . sort ( lambda x , y : cmp ( x [ 0 ] , y [ 0 ] ) )
new = [ ]
for i in results :
new . extend ( i )
results = new
headline = [ ]
2010-03-15 16:08:00 +01:00
if kind == ' package ' or kind == ' published/binary/id ' :
2009-10-08 16:40:06 +02:00
headline = [ ' # Project ' , ' # Package ' ]
2007-07-15 15:49:13 +02:00
else :
2009-06-09 19:07:02 +02:00
headline = [ ' # Project ' ]
if opts . verbose :
headline . append ( ' # Title ' )
if opts . repos_baseurl :
headline . append ( ' # URL ' )
2010-03-15 16:08:00 +01:00
if opts . binary :
headline . append ( ' # filepath ' )
2009-06-09 19:07:02 +02:00
if not opts . csv :
2010-03-10 23:36:09 +01:00
if len ( what . keys ( ) ) > 1 :
2009-06-09 19:07:02 +02:00
print ' # ' * 68
2009-08-21 03:26:37 +02:00
print ' matches for \' %s \' in %s s: \n ' % ( role_filter or search_term , kind )
2010-03-10 23:36:09 +01:00
for row in build_table ( len ( headline ) , results , headline , 2 , csv = opts . csv ) :
2009-06-09 19:07:02 +02:00
print row
2007-06-29 20:26:30 +02:00
2007-07-25 12:56:04 +02:00
2007-07-23 18:03:30 +02:00
@cmdln.option ( ' -p ' , ' --project ' , metavar = ' project ' ,
2009-12-25 18:16:35 +01:00
help = ' specify the path to a project ' )
2007-07-23 18:03:30 +02:00
@cmdln.option ( ' -n ' , ' --name ' , metavar = ' name ' ,
help = ' specify a package name ' )
@cmdln.option ( ' -t ' , ' --title ' , metavar = ' title ' ,
help = ' set a title ' )
@cmdln.option ( ' -d ' , ' --description ' , metavar = ' description ' ,
help = ' set the description of the package ' )
2007-07-30 13:12:42 +02:00
@cmdln.option ( ' ' , ' --delete-old-files ' , action = ' store_true ' ,
help = ' delete existing files from the server ' )
2007-07-30 20:11:52 +02:00
@cmdln.option ( ' -c ' , ' --commit ' , action = ' store_true ' ,
2007-08-08 17:44:14 +02:00
help = ' commit the new files ' )
2007-07-25 14:14:32 +02:00
def do_importsrcpkg ( self , subcmd , opts , srpm ) :
2007-12-10 15:23:58 +01:00
""" $ {cmd_name} : Import a new package from a src.rpm
2007-07-23 18:03:30 +02:00
A new package dir will be created inside the project dir
( if no project is specified and the current working dir is a
project dir the package will be created in this project ) . If
the package does not exist on the server it will be created
too otherwise the meta data of the existing package will be
updated ( < title / > and < description / > ) .
2008-11-29 14:32:25 +01:00
The src . rpm will be extracted into the package dir . The files
won ' t be committed unless you explicitly pass the --commit switch.
2007-07-23 18:03:30 +02:00
2007-07-25 14:21:46 +02:00
SRPM is the path of the src . rpm in the local filesystem ,
or an URL .
2007-07-25 14:14:32 +02:00
$ { cmd_usage }
2007-07-23 18:03:30 +02:00
$ { cmd_option_list }
"""
import glob
2009-09-09 17:28:21 +02:00
from util import rpmquery
2007-07-23 18:03:30 +02:00
2008-03-10 19:04:23 +01:00
if opts . delete_old_files and conf . config [ ' do_package_tracking ' ] :
# IMHO the --delete-old-files option doesn't really fit into our
# package tracking strategy
print >> sys . stderr , ' --delete-old-files is not supported anymore '
print >> sys . stderr , ' when do_package_tracking is enabled '
sys . exit ( 1 )
2007-07-25 14:21:46 +02:00
if ' :// ' in srpm :
print ' trying to fetch ' , srpm
import urlgrabber
urlgrabber . urlgrab ( srpm )
srpm = os . path . basename ( srpm )
2007-07-25 14:14:32 +02:00
srpm = os . path . abspath ( srpm )
2008-03-15 23:51:37 +01:00
if not os . path . isfile ( srpm ) :
print >> sys . stderr , ' file \' %s \' does not exist ' % srpm
sys . exit ( 1 )
2007-07-23 18:03:30 +02:00
if opts . project :
project_dir = opts . project
else :
2008-03-10 19:04:23 +01:00
project_dir = os . curdir
2007-07-23 18:03:30 +02:00
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
if conf . config [ ' do_package_tracking ' ] :
project = Project ( project_dir )
2007-07-23 18:03:30 +02:00
else :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
project = store_read_project ( project_dir )
2007-07-23 18:03:30 +02:00
2009-09-09 17:28:21 +02:00
rpmq = rpmquery . RpmQuery . query ( srpm )
title , pac , descr , url = rpmq . summary ( ) , rpmq . name ( ) , rpmq . description ( ) , rpmq . url ( )
if url is None :
url = ' '
2007-07-23 18:03:30 +02:00
if opts . title :
title = opts . title
if opts . name :
pac = opts . name
if opts . description :
descr = opts . description
2009-05-18 16:50:43 +02:00
2007-07-29 17:27:27 +02:00
# title and description can be empty
if not pac :
print >> sys . stderr , ' please specify a package name with the \' --name \' option. ' \
' The automatic detection failed '
sys . exit ( 1 )
2008-03-10 19:04:23 +01:00
olddir = os . getcwd ( )
2008-03-15 23:51:37 +01:00
if conf . config [ ' do_package_tracking ' ] :
2009-12-25 00:08:29 +01:00
createPackageDir ( os . path . join ( project . dir , pac ) , project )
os . chdir ( os . path . join ( project . dir , pac ) )
2008-03-15 23:51:37 +01:00
else :
if not os . path . exists ( os . path . join ( project_dir , pac ) ) :
apiurl = store_read_apiurl ( project_dir )
user = conf . get_apiurl_usr ( apiurl )
2008-03-10 19:04:23 +01:00
data = meta_exists ( metatype = ' pkg ' ,
path_args = ( quote_plus ( project ) , quote_plus ( pac ) ) ,
template_args = ( {
' name ' : pac ,
2008-03-15 23:51:37 +01:00
' user ' : user } ) , apiurl = apiurl )
2008-03-10 19:04:23 +01:00
if data :
data = ET . fromstring ( ' ' . join ( data ) )
data . find ( ' title ' ) . text = title
data . find ( ' description ' ) . text = ' ' . join ( descr )
2009-01-21 22:55:53 +01:00
data . find ( ' url ' ) . text = url
2008-03-10 19:04:23 +01:00
data = ET . tostring ( data )
else :
print >> sys . stderr , ' error - cannot get meta data '
sys . exit ( 1 )
edit_meta ( metatype = ' pkg ' ,
path_args = ( quote_plus ( project ) , quote_plus ( pac ) ) ,
2008-03-15 23:51:37 +01:00
data = data , apiurl = apiurl )
os . mkdir ( os . path . join ( project_dir , pac ) )
os . chdir ( os . path . join ( project_dir , pac ) )
init_package_dir ( apiurl , project , pac , os . path . join ( project , pac ) )
2007-07-30 13:12:42 +02:00
else :
2008-03-15 23:51:37 +01:00
print >> sys . stderr , ' error - local package already exists '
2007-07-30 13:12:42 +02:00
sys . exit ( 1 )
2008-03-15 23:51:37 +01:00
unpack_srcrpm ( srpm , os . getcwd ( ) )
p = Package ( os . getcwd ( ) )
if len ( p . filenamelist ) == 0 and opts . commit :
print ' Adding files to working copy... '
addFiles ( glob . glob ( ' * ' ) )
if conf . config [ ' do_package_tracking ' ] :
os . chdir ( olddir )
project . commit ( ( pac , ) )
else :
p . update_datastructs ( )
p . commit ( )
elif opts . commit and opts . delete_old_files :
for file in p . filenamelist :
p . delete_remote_source_file ( file )
p . update_local_filesmeta ( )
print ' Adding files to working copy... '
addFiles ( glob . glob ( ' * ' ) )
p . update_datastructs ( )
p . commit ( )
2007-07-23 18:03:30 +02:00
else :
2008-03-15 23:51:37 +01:00
print ' No files were committed to the server. Please ' \
' commit them manually. '
print ' Package \' %s \' only imported locally ' % pac
2007-07-23 18:03:30 +02:00
sys . exit ( 1 )
print ' Package \' %s \' imported successfully ' % pac
2007-07-25 12:56:04 +02:00
2007-07-25 14:14:32 +02:00
2007-07-25 12:56:04 +02:00
@cmdln.option ( ' -m ' , ' --method ' , default = ' GET ' , metavar = ' HTTP_METHOD ' ,
help = ' specify HTTP method to use (GET|PUT|DELETE|POST) ' )
@cmdln.option ( ' -d ' , ' --data ' , default = None , metavar = ' STRING ' ,
help = ' specify string data for e.g. POST ' )
@cmdln.option ( ' -f ' , ' --file ' , default = None , metavar = ' FILE ' ,
help = ' specify filename for e.g. PUT or DELETE ' )
2009-05-18 16:50:43 +02:00
@cmdln.option ( ' -a ' , ' --add-header ' , default = None , metavar = ' NAME STRING ' ,
2008-03-16 21:46:16 +01:00
nargs = 2 , action = ' append ' , dest = ' headers ' ,
help = ' add the specified header to the request ' )
2009-06-04 16:14:01 +02:00
def do_api ( self , subcmd , opts , url ) :
2007-07-25 12:56:04 +02:00
""" $ {cmd_name} : Issue an arbitrary request to the API
Useful for testing .
URL can be specified either partially ( only the path component ) , or fully
with URL scheme and hostname ( ' http://... ' ) .
Note the global - A and - H options ( see osc help ) .
Examples :
2009-06-04 16:14:01 +02:00
osc api / source / home : user
osc api - m PUT - f / etc / fstab source / home : user / test5 / myfstab
2007-07-25 12:56:04 +02:00
$ { cmd_usage }
$ { cmd_option_list }
"""
if not opts . method in [ ' GET ' , ' PUT ' , ' POST ' , ' DELETE ' ] :
sys . exit ( ' unknown method %s ' % opts . method )
if not url . startswith ( ' http ' ) :
if not url . startswith ( ' / ' ) :
url = ' / ' + url
2009-09-08 15:24:54 +02:00
url = conf . config [ ' apiurl ' ] + url
2007-07-25 12:56:04 +02:00
2008-03-16 21:46:16 +01:00
if opts . headers :
opts . headers = dict ( opts . headers )
2009-05-18 16:50:43 +02:00
r = http_request ( opts . method ,
url ,
data = opts . data ,
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
file = opts . file ,
2009-05-18 16:50:43 +02:00
headers = opts . headers )
2007-07-25 12:56:04 +02:00
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
out = r . read ( )
2007-07-25 12:56:04 +02:00
sys . stdout . write ( out )
2009-10-22 11:43:58 +02:00
@cmdln.option ( ' -v ' , ' --verbose ' , action = ' store_true ' ,
help = ' show more information ' )
@cmdln.option ( ' --nodevelproject ' , action = ' store_true ' ,
help = ' do not follow a defined devel project ' \
' (primary project where a package is developed) ' )
@cmdln.option ( ' -e ' , ' --email ' , action = ' store_true ' ,
help = ' show email addresses instead of user names ' )
def do_bugowner ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Show bugowners of a project/package
2007-07-25 12:56:04 +02:00
2010-02-28 02:30:13 +01:00
osc bugowner PRJ
2009-10-22 11:43:58 +02:00
osc bugowner PRJ PKG
Shortcut for osc maintainer - B [ PRJ ] PKG
2009-11-10 01:56:52 +01:00
PRJ defaults to ' %(getpac_default_project)s ' .
Prints bugowner if defined , or maintainer otherwise .
2009-10-22 11:43:58 +02:00
$ { cmd_option_list }
"""
2010-01-13 10:03:14 +01:00
opts . role = ( )
2009-11-10 01:56:52 +01:00
opts . bugowner = True
opts . bugowner_only = None
opts . add = None
opts . delete = None
opts . devel_project = None
2009-10-22 11:43:58 +02:00
if len ( args ) == 1 :
print >> sys . stderr , ' defaulting to %s / %s ' % ( conf . config [ ' getpac_default_project ' ] , args [ 0 ] )
# python has no args.unshift ???
args = [ conf . config [ ' getpac_default_project ' ] , args [ 0 ] ]
2009-11-10 01:56:52 +01:00
return self . do_maintainer ( subcmd , opts , * args )
2009-10-22 11:43:58 +02:00
2009-12-25 17:19:44 +01:00
@cmdln.option ( ' -b ' , ' --bugowner-only ' , action = ' store_true ' ,
2009-06-18 18:20:49 +02:00
help = ' Show only the bugowner ' )
2009-10-22 11:43:58 +02:00
@cmdln.option ( ' -B ' , ' --bugowner ' , action = ' store_true ' ,
help = ' Show only the bugowner if defined, or maintainer otherwise ' )
2007-09-03 12:17:26 +02:00
@cmdln.option ( ' -e ' , ' --email ' , action = ' store_true ' ,
help = ' show email addresses instead of user names ' )
2009-06-18 18:20:49 +02:00
@cmdln.option ( ' --nodevelproject ' , action = ' store_true ' ,
help = ' do not follow a defined devel project ' \
' (primary project where a package is developed) ' )
2007-09-03 18:18:37 +02:00
@cmdln.option ( ' -v ' , ' --verbose ' , action = ' store_true ' ,
help = ' show more information ' )
2008-05-20 10:29:54 +02:00
@cmdln.option ( ' -D ' , ' --devel-project ' , metavar = ' devel_project ' ,
help = ' define the project where this package is primarily developed ' )
2007-09-12 20:01:13 +02:00
@cmdln.option ( ' -a ' , ' --add ' , metavar = ' user ' ,
2009-12-30 21:54:57 +01:00
help = ' add a new maintainer/bugowner (can be specified via --role) ' )
2007-09-12 20:01:13 +02:00
@cmdln.option ( ' -d ' , ' --delete ' , metavar = ' user ' ,
2009-12-30 21:54:57 +01:00
help = ' delete a maintainer/bugowner (can be specified via --role) ' )
2009-12-25 17:31:13 +01:00
@cmdln.option ( ' -r ' , ' --role ' , metavar = ' role ' , action = ' append ' , default = [ ] ,
2009-06-19 15:57:27 +02:00
help = ' Specify user role ' )
2007-09-03 12:17:26 +02:00
def do_maintainer ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Show maintainers of a project/package
2009-05-18 16:50:43 +02:00
2007-09-03 12:17:26 +02:00
To be used like this :
2009-05-18 16:50:43 +02:00
2007-09-12 20:01:13 +02:00
osc maintainer PRJ < options >
2009-05-18 16:50:43 +02:00
or
2007-09-12 20:01:13 +02:00
osc maintainer PRJ PKG < options >
2009-05-18 16:50:43 +02:00
2007-09-03 12:17:26 +02:00
$ { cmd_usage }
$ { cmd_option_list }
"""
2009-05-18 16:50:43 +02:00
2007-09-12 20:01:13 +02:00
pac = None
2009-12-26 14:22:34 +01:00
root = None
2009-12-25 17:19:44 +01:00
roles = [ ' bugowner ' , ' maintainer ' ]
2009-12-25 17:31:13 +01:00
if len ( opts . role ) :
roles = opts . role
2009-12-25 17:19:44 +01:00
if opts . bugowner_only or opts . bugowner :
2009-06-18 18:20:49 +02:00
roles = [ ' bugowner ' ]
2007-09-03 12:17:26 +02:00
if len ( args ) == 1 :
2007-09-12 20:01:13 +02:00
prj = args [ 0 ]
2007-09-03 12:17:26 +02:00
elif len ( args ) == 2 :
2007-09-12 20:01:13 +02:00
prj = args [ 0 ]
pac = args [ 1 ]
2007-09-03 12:17:26 +02:00
else :
2010-02-02 16:14:00 +01:00
raise oscerr . WrongArgs ( ' Wrong number of arguments. ' )
2009-05-18 16:50:43 +02:00
2009-06-18 18:20:49 +02:00
if opts . add :
2009-08-26 16:22:54 +02:00
for role in roles :
addPerson ( conf . config [ ' apiurl ' ] , prj , pac , opts . add , role )
2007-09-12 20:01:13 +02:00
elif opts . delete :
2009-08-26 16:22:54 +02:00
for role in roles :
delPerson ( conf . config [ ' apiurl ' ] , prj , pac , opts . delete , role )
2008-05-20 10:29:54 +02:00
elif opts . devel_project :
2009-12-25 17:19:44 +01:00
# XXX: does it really belong to this command?
2009-06-18 18:20:49 +02:00
setDevelProject ( conf . config [ ' apiurl ' ] , prj , pac , opts . devel_project )
2009-06-23 12:06:31 +02:00
else :
2010-02-02 16:14:00 +01:00
if pac :
m = show_package_meta ( conf . config [ ' apiurl ' ] , prj , pac )
root = ET . fromstring ( ' ' . join ( m ) )
if not opts . nodevelproject :
while root . findall ( ' devel ' ) :
d = root . find ( ' devel ' )
prj = d . get ( ' project ' , prj )
pac = d . get ( ' package ' , pac )
if opts . verbose :
print " Following to the development space: %s / %s " % ( prj , pac )
m = show_package_meta ( conf . config [ ' apiurl ' ] , prj , pac )
root = ET . fromstring ( ' ' . join ( m ) )
if not root . findall ( ' person ' ) :
if opts . verbose :
print " No dedicated persons in package defined, showing the project persons. "
pac = None
m = show_project_meta ( conf . config [ ' apiurl ' ] , prj )
root = ET . fromstring ( ' ' . join ( m ) )
else :
m = show_project_meta ( conf . config [ ' apiurl ' ] , prj )
root = ET . fromstring ( ' ' . join ( m ) )
2009-06-18 18:20:49 +02:00
# showing the maintainers
2009-12-25 17:19:44 +01:00
maintainers = { }
2009-12-26 14:22:34 +01:00
for person in root . findall ( ' person ' ) :
2009-12-25 17:19:44 +01:00
maintainers . setdefault ( person . get ( ' role ' ) , [ ] ) . append ( person . get ( ' userid ' ) )
2009-06-18 18:20:49 +02:00
for role in roles :
2009-12-25 17:19:44 +01:00
if opts . bugowner and not len ( maintainers . get ( role , [ ] ) ) :
role = ' maintainer '
2010-02-02 16:15:06 +01:00
if pac :
print " %s of %s / %s : " % ( role , prj , pac )
else :
print " %s of %s : " % ( role , prj )
2009-06-18 18:20:49 +02:00
if opts . email :
emails = [ ]
2009-12-25 17:19:44 +01:00
for maintainer in maintainers . get ( role , [ ] ) :
2009-06-18 18:20:49 +02:00
user = get_user_data ( conf . config [ ' apiurl ' ] , maintainer , ' email ' )
2009-12-12 15:02:58 +01:00
if len ( user ) :
2009-06-18 18:20:49 +02:00
emails . append ( ' ' . join ( user ) )
2009-12-25 17:19:44 +01:00
print ' , ' . join ( emails ) or ' - '
2009-06-18 18:20:49 +02:00
elif opts . verbose :
userdata = [ ]
2009-12-25 17:19:44 +01:00
for maintainer in maintainers . get ( role , [ ] ) :
2010-02-02 16:15:06 +01:00
user = get_user_data ( conf . config [ ' apiurl ' ] , maintainer , ' login ' , ' realname ' , ' email ' )
userdata . append ( user [ 0 ] )
if user [ 1 ] != ' - ' :
userdata . append ( " %s < %s > " % ( user [ 1 ] , user [ 2 ] ) )
else :
userdata . append ( user [ 2 ] )
for row in build_table ( 2 , userdata , None , 3 ) :
2009-06-18 18:20:49 +02:00
print row
else :
2009-12-25 17:19:44 +01:00
print ' , ' . join ( maintainers . get ( role , [ ] ) ) or ' - '
print
2007-09-03 12:17:26 +02:00
2008-01-15 19:58:58 +01:00
@cmdln.option ( ' -r ' , ' --revision ' , metavar = ' rev ' ,
help = ' print out the specified revision ' )
2009-08-20 21:28:05 +02:00
@cmdln.option ( ' -e ' , ' --expand ' , action = ' store_true ' ,
2010-03-08 10:56:29 +01:00
help = ' force expansion of linked packages. ' )
@cmdln.option ( ' -u ' , ' --unexpand ' , action = ' store_true ' ,
help = ' always work with unexpanded packages. ' )
2007-11-02 19:18:30 +01:00
def do_cat ( self , subcmd , opts , * args ) :
2007-12-10 15:23:58 +01:00
""" $ {cmd_name} : Output the content of a file to standard output
2007-07-25 12:56:04 +02:00
2007-11-02 19:18:30 +01:00
Examples :
osc cat project package file
osc cat project / package / file
2009-09-03 19:28:27 +02:00
osc cat http : / / api . opensuse . org / build / . . . / _log
osc cat http : / / api . opensuse . org / source / . . / _link
2007-11-02 19:18:30 +01:00
$ { cmd_usage }
$ { cmd_option_list }
"""
2009-09-03 19:28:27 +02:00
if len ( args ) == 1 and ( args [ 0 ] . startswith ( ' http:// ' ) or
args [ 0 ] . startswith ( ' https:// ' ) ) :
2009-10-20 16:30:15 +02:00
opts . method = ' GET '
opts . headers = None
opts . data = None
opts . file = None
return self . do_api ( ' list ' , opts , * args )
2009-09-03 19:28:27 +02:00
2007-11-02 19:18:30 +01:00
args = slash_split ( args )
if len ( args ) != 3 :
Merged revisions 3774-3775,3779,3781-3782,3787,3789-3793,3798,3802,3805,3817-3822,3827,3829-3830,3837-3839,3841-3842,3848-3850 via svnmerge from
https://forgesvn1.novell.com/svn/opensuse/branches/buildservice/osc-exception-handling
........
r3774 | poeml | 2008-04-22 17:39:45 +0200 (Tue, 22 Apr 2008) | 3 lines
A first draft on implement systematic exception handling:
Add errors.py with some exceptions defined, and babysitter.py to handle them
........
r3775 | poeml | 2008-04-22 22:34:12 +0200 (Tue, 22 Apr 2008) | 9 lines
- new global options:
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
-t, --traceback print call trace in case of errors
- traceback and post_mortem can also be set in .oscrc.
- catch more errors (HTTPError).
- make config accessible from outside of the Osc instance, by making it a class
attribute
........
r3779 | poeml | 2008-04-23 00:55:49 +0200 (Wed, 23 Apr 2008) | 5 lines
- new global option:
-d, --debug print info useful for debugging
- catch some more errors (HTTPError), with OscHTTPError which isn't very
advanced yet.
........
r3781 | Marcus_H | 2008-04-23 01:02:00 +0200 (Wed, 23 Apr 2008) | 2 lines
- added OscConfigError class (just for testing).
- small change in the signature of the OscBaseError constructor (actually we should get rid of the 'args' tuple because it will be deprecated sooner or later
........
r3782 | Marcus_H | 2008-04-23 02:02:13 +0200 (Wed, 23 Apr 2008) | 2 lines
- access the prg.conf.config dict in a save way - this way we avoid AttributeErrors if the prg.conf.config dict doesn't exist
- in case of an configparser error we have to use the prg.options object directly (this was removed in r3781 by accident)
........
r3787 | poeml | 2008-04-23 09:23:56 +0200 (Wed, 23 Apr 2008) | 4 lines
- remove local exception handling from do_req
- for HTTPError, print details (headers and response) when in debug mode
- catch AttributeError
........
r3789 | poeml | 2008-04-23 16:23:14 +0200 (Wed, 23 Apr 2008) | 4 lines
- errors: add two new classes named OscWrongOptionsError and OscWrongArgsError
- commandline: raise instances of the new errors in a number of places
- commandline: add get_cmd_help() to Osc instance which returns the formatted help of a subcommand
........
r3790 | Marcus_H | 2008-04-23 16:48:28 +0200 (Wed, 23 Apr 2008) | 4 lines
- added 2 new exception classes: OscNoConfigfileError and OscIOError
- added new method write_config() to the conf.py module: This method writes osc's configuration file
- minor cleanups in the conf module
........
r3791 | poeml | 2008-04-23 17:11:07 +0200 (Wed, 23 Apr 2008) | 3 lines
small compatibility fix for r3790: try-except-finally isn't supported in
python-2.4.2, thus do the same as try-except inside a try-finally.
........
r3792 | poeml | 2008-04-23 17:37:53 +0200 (Wed, 23 Apr 2008) | 2 lines
fix up the remaining places regarding handling of errors related to commandline parsing
........
r3793 | poeml | 2008-04-23 17:40:34 +0200 (Wed, 23 Apr 2008) | 3 lines
raise a NoWorkingCopyError in osc.core.store_read_project() in case of an
IOError
........
r3798 | Marcus_H | 2008-04-23 23:55:24 +0200 (Wed, 23 Apr 2008) | 1 line
ported -r3797 from trunk
........
r3802 | Marcus_H | 2008-04-24 11:00:55 +0200 (Thu, 24 Apr 2008) | 1 line
ported -r3801 from trunk
........
r3805 | poeml | 2008-04-24 12:52:30 +0200 (Thu, 24 Apr 2008) | 2 lines
raise OscHTTPError in show_pattern_meta(), replacing local error handling
........
r3817 | poeml | 2008-04-24 20:21:32 +0200 (Thu, 24 Apr 2008) | 9 lines
- remove errors.OscHTTPError again.
it seems simpler to use urllib2.HTTPError instead (and just add a specific
error text message where appropriate, and re-raise)
- for 404s, check out _which_ part was not found
it is very ugly, but may be considered Good for pragmatic reasons
- removed local exception handling and workaround for returned 500's from
delete_package() and delete_project(), thereby getting rid of 4 possible exit
points.
........
r3818 | Marcus_H | 2008-04-24 22:36:17 +0200 (Thu, 24 Apr 2008) | 1 line
- this check is superfluous because every HTTPError instance has a code attribute
........
r3819 | poeml | 2008-04-25 00:39:39 +0200 (Fri, 25 Apr 2008) | 1 line
remove a forgotten debug line from core.delete_project()
........
r3820 | poeml | 2008-04-25 10:07:58 +0200 (Fri, 25 Apr 2008) | 2 lines
- ditch local error handling from wipebinaries(), rebuild(), and abortbuild()
........
r3821 | poeml | 2008-04-25 10:56:38 +0200 (Fri, 25 Apr 2008) | 2 lines
It is never needed to import the exception module.
........
r3822 | poeml | 2008-04-25 11:13:39 +0200 (Fri, 25 Apr 2008) | 4 lines
- when going into the debugger with --post-mortem, always print a traceback before
(thus implying -t)
- do not jump into the debugger if not on a TTY, or working in interactive mode
........
r3827 | poeml | 2008-04-25 13:07:46 +0200 (Fri, 25 Apr 2008) | 9 lines
- add errors.OscWorkingCopyOutdated, which takes a tuple with three args:
path to working copy, current rev, expected rev
- add handler for urllib2.URLError errors to the babysitter
- simplify the OscWrongArgsError and OscWrongOptionsError handlers, by removing
the extra line "Sorry, wrong ..." that was printed before the messages given
when the error was raised.
- remove one more errors.OscHTTPError which was still there, and raise
urllib2.HTTPError instead (show_package_meta())
........
r3829 | poeml | 2008-04-25 14:19:10 +0200 (Fri, 25 Apr 2008) | 11 lines
- comment some methods in osc.core which are used by nearly all do_* methods in
osc.commandline
- improve "is not a package/project dir" error messages, by printing the
absolute path tried, instead of '.' for the cwd
- make core.store_read_package() raise a proper NoWorkingCopyError instead of
terminating
- give attribution to things in babysitter.py copied from mercurial
- prefix HTTPError exceptions with 'Server returned an error:'
- remove obsolete local error handling from do_prjresults(), do_importsrcpkg(),
do_repos()
........
r3830 | poeml | 2008-04-25 14:29:35 +0200 (Fri, 25 Apr 2008) | 1 line
catch IOError exceptions in the babysitter
........
r3837 | poeml | 2008-04-25 17:27:36 +0200 (Fri, 25 Apr 2008) | 5 lines
- do_remotebuildlog: raise errors for wrong arguments, remove exits
- raise AttributeError in make_meta_url() instead of exiting
- delete unused method core.delete_server_files()
- replace exit call inside make_meta_url() with an AttributeError
........
r3838 | poeml | 2008-04-25 17:49:18 +0200 (Fri, 25 Apr 2008) | 1 line
simplify the check in do_checkout if a project exists, by using show_project_meta() instead of meta_exists
........
r3839 | poeml | 2008-04-25 18:31:26 +0200 (Fri, 25 Apr 2008) | 6 lines
- commandline do_checkout(): change the order of the two checks, first do the
(cheaper) check for existing directory
- core.core checkout_package(): simplify the check in if the package
exists, by using show_package_meta() instead of meta_exists
Let it throw an exception, instead of using sys.exit().
........
r3841 | Marcus_H | 2008-04-27 15:48:06 +0200 (Sun, 27 Apr 2008) | 5 lines
- added 2 new exception classes: PackageError() and PackageExistsError. The PackageError() class is meant to be the base class for all subsequent package exceptions.
- get rid of 2 sys.exit(1) calls
- make the update() method of the Project() class safer: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- minor fix in delPackage(): use getTransActPath() when printing out the filename
........
r3842 | Marcus_H | 2008-04-27 16:52:55 +0200 (Sun, 27 Apr 2008) | 3 lines
- make the commit() method safe: in any case we have to write the _packages file otherwise the package tracking will be screwed up.
- removed another sys.exit(1): raise an exception if a package is missing when doing a commit. For now we use the PackageExistsError() exception but this might change in the future (updated description of PackageExistsError() according to this change)
........
r3848 | poeml | 2008-04-28 12:46:45 +0200 (Mon, 28 Apr 2008) | 3 lines
rename several error classes, dropping the "Osc" prefix, and "Error" suffix in
cases where they don't really make sense.
........
r3849 | poeml | 2008-04-28 12:57:32 +0200 (Mon, 28 Apr 2008) | 3 lines
- rename osc.errors module to osc.oscerr, to make it easier to import it from
other programs and have a crystal clear namespace
........
r3850 | poeml | 2008-04-28 13:26:12 +0200 (Mon, 28 Apr 2008) | 2 lines
split PackageExists exception class into PackageExists and PackageMissing
........
2008-04-28 18:37:44 +02:00
raise oscerr . WrongArgs ( ' Wrong number of arguments. ' )
2008-01-15 19:58:58 +01:00
rev , dummy = parseRevisionOption ( opts . revision )
2007-12-10 15:23:58 +01:00
2009-08-20 21:28:05 +02:00
query = { }
2009-04-09 17:52:59 +02:00
if opts . revision :
2009-08-20 21:28:05 +02:00
query [ ' rev ' ] = opts . revision
if opts . expand :
query [ ' rev ' ] = show_upstream_srcmd5 ( conf . config [ ' apiurl ' ] , args [ 0 ] , args [ 1 ] , expand = True , revision = opts . revision )
2009-04-09 17:52:59 +02:00
u = makeurl ( conf . config [ ' apiurl ' ] , [ ' source ' , args [ 0 ] , args [ 1 ] , args [ 2 ] ] , query = query )
2010-03-08 01:31:36 +01:00
try :
for data in streamfile ( u ) :
sys . stdout . write ( data )
except urllib2 . HTTPError , e :
2010-03-08 10:56:29 +01:00
if e . code == 404 and not opts . expand and not opts . unexpand :
2010-03-08 01:31:36 +01:00
print >> sys . stderr , ' expanding link... '
query [ ' rev ' ] = show_upstream_srcmd5 ( conf . config [ ' apiurl ' ] , args [ 0 ] , args [ 1 ] , expand = True , revision = opts . revision )
u = makeurl ( conf . config [ ' apiurl ' ] , [ ' source ' , args [ 0 ] , args [ 1 ] , args [ 2 ] ] , query = query )
for data in streamfile ( u ) :
sys . stdout . write ( data )
else :
e . osc_msg = ' If linked, try: cat -e '
raise e
2007-12-10 15:23:58 +01:00
2009-04-21 18:52:26 +02:00
# helper function to download a file from a specific revision
def download ( self , name , md5 , dir , destfile ) :
2009-05-22 17:00:31 +02:00
o = open ( destfile , ' wb ' )
2009-04-22 11:06:13 +02:00
if md5 != ' ' :
query = { ' rev ' : dir [ ' srcmd5 ' ] }
u = makeurl ( dir [ ' apiurl ' ] , [ ' source ' , dir [ ' project ' ] , dir [ ' package ' ] , pathname2url ( name ) ] , query = query )
for buf in streamfile ( u , http_GET , BUFSIZE ) :
o . write ( buf )
o . close
2009-04-21 18:52:26 +02:00
2009-04-23 10:58:21 +02:00
2009-04-21 18:52:26 +02:00
@cmdln.option ( ' -d ' , ' --destdir ' , default = ' repairlink ' , metavar = ' DIR ' ,
2009-04-22 11:06:13 +02:00
help = ' destination directory ' )
2009-04-23 10:58:21 +02:00
def do_repairlink ( self , subcmd , opts , * args ) :
2009-04-22 11:06:13 +02:00
""" $ {cmd_name} : Repair a broken source link
2009-04-23 10:58:21 +02:00
This command checks out a package with merged source changes . It uses
a 3 - way merge to resolve file conflicts . After reviewing / repairing
2009-10-20 16:30:15 +02:00
the merge , use ' osc resolved ... ' and ' osc ci ' to re - create a
2009-08-20 21:28:05 +02:00
working source link .
2009-04-23 10:58:21 +02:00
2009-05-18 16:50:43 +02:00
usage :
2009-05-04 11:13:35 +02:00
* For merging conflicting changes of a checkout package :
2009-04-23 10:58:21 +02:00
osc repairlink
2009-05-04 11:13:35 +02:00
* Check out a package and merge changes :
2009-04-23 10:58:21 +02:00
osc repairlink PROJECT PACKAGE
2009-05-04 11:13:35 +02:00
* Pull conflicting changes from one project into another one :
osc repairlink PROJECT PACKAGE INTO_PROJECT [ INTO_PACKAGE ]
2009-04-22 11:06:13 +02:00
$ { cmd_option_list }
"""
apiurl = conf . config [ ' apiurl ' ]
2009-05-07 20:43:04 +02:00
if len ( args ) > = 3 and len ( args ) < = 4 :
2009-04-23 10:58:21 +02:00
prj = args [ 0 ]
2009-05-04 11:13:35 +02:00
package = target_package = args [ 1 ]
target_prj = args [ 2 ]
if len ( args ) == 4 :
2009-10-20 16:30:15 +02:00
target_package = args [ 3 ]
2009-05-07 20:43:04 +02:00
elif len ( args ) == 2 :
2009-05-04 11:13:35 +02:00
target_prj = prj = args [ 0 ]
target_package = package = args [ 1 ]
2009-05-07 20:43:04 +02:00
elif is_package_dir ( os . getcwd ( ) ) :
apiurl = store_read_apiurl ( os . getcwd ( ) )
target_prj = prj = store_read_project ( os . getcwd ( ) )
target_package = package = store_read_package ( os . getcwd ( ) )
2009-04-23 10:58:21 +02:00
else :
2009-05-07 20:43:04 +02:00
raise oscerr . WrongArgs ( ' Please specify project and package ' )
2009-04-22 11:06:13 +02:00
2009-04-27 12:09:38 +02:00
# first try stored reference, then lastworking
query = { ' rev ' : ' latest ' }
2009-04-22 11:06:13 +02:00
u = makeurl ( apiurl , [ ' source ' , prj , package ] , query = query )
f = http_GET ( u )
root = ET . parse ( f ) . getroot ( )
linkinfo = root . find ( ' linkinfo ' )
if linkinfo == None :
raise oscerr . APIError ( ' package is not a source link ' )
if linkinfo . get ( ' error ' ) == None :
raise oscerr . APIError ( ' source link is not broken ' )
2009-04-27 12:09:38 +02:00
workingrev = None
baserev = linkinfo . get ( ' baserev ' )
if baserev != None :
query = { ' rev ' : ' latest ' , ' linkrev ' : baserev }
u = makeurl ( apiurl , [ ' source ' , prj , package ] , query = query )
f = http_GET ( u )
root = ET . parse ( f ) . getroot ( )
linkinfo = root . find ( ' linkinfo ' )
if linkinfo . get ( ' error ' ) == None :
workingrev = linkinfo . get ( ' xsrcmd5 ' )
if workingrev == None :
query = { ' lastworking ' : 1 }
u = makeurl ( apiurl , [ ' source ' , prj , package ] , query = query )
f = http_GET ( u )
root = ET . parse ( f ) . getroot ( )
linkinfo = root . find ( ' linkinfo ' )
if linkinfo == None :
raise oscerr . APIError ( ' package is not a source link ' )
if linkinfo . get ( ' error ' ) == None :
raise oscerr . APIError ( ' source link is not broken ' )
workingrev = linkinfo . get ( ' lastworking ' )
if workingrev == None :
raise oscerr . APIError ( ' source link never worked ' )
print " using last working link target "
else :
print " using link target of last commit "
2009-04-22 11:06:13 +02:00
query = { ' expand ' : 1 , ' emptylink ' : 1 }
u = makeurl ( apiurl , [ ' source ' , prj , package ] , query = query )
f = http_GET ( u )
meta = f . readlines ( )
2009-12-26 14:22:34 +01:00
root_new = ET . fromstring ( ' ' . join ( meta ) )
2009-04-22 15:14:17 +02:00
dir_new = { ' apiurl ' : apiurl , ' project ' : prj , ' package ' : package }
2009-04-22 11:06:13 +02:00
dir_new [ ' srcmd5 ' ] = root_new . get ( ' srcmd5 ' )
2009-05-07 21:13:50 +02:00
dir_new [ ' entries ' ] = [ [ n . get ( ' name ' ) , n . get ( ' md5 ' ) ] for n in root_new . findall ( ' entry ' ) ]
2009-04-22 11:06:13 +02:00
2009-04-27 12:09:38 +02:00
query = { ' rev ' : workingrev }
2009-04-22 11:06:13 +02:00
u = makeurl ( apiurl , [ ' source ' , prj , package ] , query = query )
f = http_GET ( u )
root_oldpatched = ET . parse ( f ) . getroot ( )
linkinfo_oldpatched = root_oldpatched . find ( ' linkinfo ' )
if linkinfo_oldpatched == None :
2009-04-27 12:09:38 +02:00
raise oscerr . APIError ( ' working rev is not a source link? ' )
2009-04-22 11:06:13 +02:00
if linkinfo_oldpatched . get ( ' error ' ) != None :
2009-04-27 12:09:38 +02:00
raise oscerr . APIError ( ' working rev is not working? ' )
2009-04-22 15:14:17 +02:00
dir_oldpatched = { ' apiurl ' : apiurl , ' project ' : prj , ' package ' : package }
2009-04-22 11:06:13 +02:00
dir_oldpatched [ ' srcmd5 ' ] = root_oldpatched . get ( ' srcmd5 ' )
2009-05-07 21:13:50 +02:00
dir_oldpatched [ ' entries ' ] = [ [ n . get ( ' name ' ) , n . get ( ' md5 ' ) ] for n in root_oldpatched . findall ( ' entry ' ) ]
2009-04-22 11:06:13 +02:00
query = { }
query [ ' rev ' ] = linkinfo_oldpatched . get ( ' srcmd5 ' )
u = makeurl ( apiurl , [ ' source ' , linkinfo_oldpatched . get ( ' project ' ) , linkinfo_oldpatched . get ( ' package ' ) ] , query = query )
f = http_GET ( u )
root_old = ET . parse ( f ) . getroot ( )
2009-04-22 15:14:17 +02:00
dir_old = { ' apiurl ' : apiurl }
2009-04-22 11:06:13 +02:00
dir_old [ ' project ' ] = linkinfo_oldpatched . get ( ' project ' )
dir_old [ ' package ' ] = linkinfo_oldpatched . get ( ' package ' )
2009-04-22 15:14:17 +02:00
dir_old [ ' srcmd5 ' ] = root_old . get ( ' srcmd5 ' )
2009-05-07 21:13:50 +02:00
dir_old [ ' entries ' ] = [ [ n . get ( ' name ' ) , n . get ( ' md5 ' ) ] for n in root_old . findall ( ' entry ' ) ]
2009-04-22 11:06:13 +02:00
entries_old = dict ( dir_old [ ' entries ' ] )
entries_oldpatched = dict ( dir_oldpatched [ ' entries ' ] )
entries_new = dict ( dir_new [ ' entries ' ] )
entries = { }
entries . update ( entries_old )
entries . update ( entries_oldpatched )
entries . update ( entries_new )
destdir = opts . destdir
if os . path . isdir ( destdir ) :
shutil . rmtree ( destdir )
os . mkdir ( destdir )
olddir = os . getcwd ( )
os . chdir ( destdir )
2009-05-04 11:13:35 +02:00
init_package_dir ( apiurl , target_prj , target_package , destdir , files = False )
2009-04-22 11:06:13 +02:00
os . chdir ( olddir )
2009-10-20 16:30:15 +02:00
store_write_string ( destdir , ' _files ' , ' ' . join ( meta ) )
store_write_string ( destdir , ' _linkrepair ' , ' ' )
2009-04-22 11:06:13 +02:00
pac = Package ( destdir )
storedir = os . path . join ( destdir , store )
for name in sorted ( entries . keys ( ) ) :
md5_old = entries_old . get ( name , ' ' )
md5_new = entries_new . get ( name , ' ' )
md5_oldpatched = entries_oldpatched . get ( name , ' ' )
if md5_new != ' ' :
self . download ( name , md5_new , dir_new , os . path . join ( storedir , name ) )
if md5_old == md5_new :
if md5_oldpatched == ' ' :
pac . put_on_deletelist ( name )
continue
print statfrmt ( ' ' , name )
self . download ( name , md5_oldpatched , dir_oldpatched , os . path . join ( destdir , name ) )
continue
if md5_old == md5_oldpatched :
if md5_new == ' ' :
continue
2009-04-23 10:58:21 +02:00
print statfrmt ( ' U ' , name )
2009-04-22 11:06:13 +02:00
shutil . copy2 ( os . path . join ( storedir , name ) , os . path . join ( destdir , name ) )
continue
if md5_new == md5_oldpatched :
if md5_new == ' ' :
continue
print statfrmt ( ' G ' , name )
shutil . copy2 ( os . path . join ( storedir , name ) , os . path . join ( destdir , name ) )
continue
self . download ( name , md5_oldpatched , dir_oldpatched , os . path . join ( destdir , name + ' .mine ' ) )
if md5_new != ' ' :
shutil . copy2 ( os . path . join ( storedir , name ) , os . path . join ( destdir , name + ' .new ' ) )
else :
self . download ( name , md5_new , dir_new , os . path . join ( destdir , name + ' .new ' ) )
self . download ( name , md5_old , dir_old , os . path . join ( destdir , name + ' .old ' ) )
2009-04-23 11:03:59 +02:00
if binary_file ( os . path . join ( destdir , name + ' .mine ' ) ) or \
binary_file ( os . path . join ( destdir , name + ' .old ' ) ) or \
binary_file ( os . path . join ( destdir , name + ' .new ' ) ) :
shutil . copy2 ( os . path . join ( destdir , name + ' .new ' ) , os . path . join ( destdir , name ) )
print statfrmt ( ' C ' , name )
pac . put_on_conflictlist ( name )
continue
2009-05-22 17:00:31 +02:00
o = open ( os . path . join ( destdir , name ) , ' wb ' )
2010-03-05 11:45:35 +01:00
code = subprocess . call ( [ ' diff3 ' , ' -m ' , ' -E ' ,
2009-04-22 11:06:13 +02:00
' -L ' , ' .mine ' ,
2009-04-21 18:52:26 +02:00
os . path . join ( destdir , name + ' .mine ' ) ,
2009-04-22 11:06:13 +02:00
' -L ' , ' .old ' ,
2009-04-21 18:52:26 +02:00
os . path . join ( destdir , name + ' .old ' ) ,
2009-04-22 11:06:13 +02:00
' -L ' , ' .new ' ,
2009-04-21 18:52:26 +02:00
os . path . join ( destdir , name + ' .new ' ) ,
2009-04-22 11:06:13 +02:00
] , stdout = o )
if code == 0 :
2009-04-23 10:58:21 +02:00
print statfrmt ( ' G ' , name )
2009-04-27 12:09:38 +02:00
os . unlink ( os . path . join ( destdir , name + ' .mine ' ) )
os . unlink ( os . path . join ( destdir , name + ' .old ' ) )
os . unlink ( os . path . join ( destdir , name + ' .new ' ) )
2009-04-22 11:06:13 +02:00
elif code == 1 :
print statfrmt ( ' C ' , name )
pac . put_on_conflictlist ( name )
else :
print statfrmt ( ' ? ' , name )
pac . put_on_conflictlist ( name )
pac . write_deletelist ( )
pac . write_conflictlist ( )
print
print ' Please change into the \' %s \' directory, ' % destdir
2009-08-20 21:28:05 +02:00
print ' fix the conflicts (files marked with \' C \' above), '
print ' run \' osc resolved ... \' , and commit the changes. '
2009-04-21 18:52:26 +02:00
2009-10-16 16:16:25 +02:00
2009-12-17 17:16:56 +01:00
def do_pull ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : merge the changes of the link target into your working copy.
$ { cmd_option_list }
"""
if not is_package_dir ( ' . ' ) :
2009-12-17 20:20:35 +01:00
raise oscerr . NoWorkingCopy ( ' Error: \' %s \' is not an osc working copy. ' % os . path . abspath ( ' . ' ) )
p = Package ( ' . ' )
2009-12-17 17:16:56 +01:00
# check if everything is committed
2009-12-17 20:20:35 +01:00
for filename in p . filenamelist :
if p . status ( filename ) != ' ' :
raise oscerr . WrongArgs ( ' Please commit your local changes first! ' )
2009-12-17 17:16:56 +01:00
# check if we need to update
upstream_rev = p . latest_rev ( )
if p . rev != upstream_rev :
2009-12-17 20:20:35 +01:00
raise oscerr . WorkingCopyOutdated ( ( p . absdir , p . rev , upstream_rev ) )
elif not p . islink ( ) :
raise oscerr . WrongArgs ( ' osc pull only works on linked packages. ' )
elif not p . isexpanded ( ) :
raise oscerr . WrongArgs ( ' osc pull only works on expanded links. ' )
2010-01-11 17:00:24 +01:00
linkinfo = p . linkinfo
baserev = linkinfo . baserev
if baserev == None :
raise oscerr . WrongArgs ( ' osc pull only works on links containing a base revision. ' )
2009-12-17 20:20:35 +01:00
2010-01-11 17:00:24 +01:00
# get revisions we need
query = { ' expand ' : 1 , ' emptylink ' : 1 }
u = makeurl ( p . apiurl , [ ' source ' , p . prjname , p . name ] , query = query )
f = http_GET ( u )
meta = f . readlines ( )
root_new = ET . fromstring ( ' ' . join ( meta ) )
linkinfo_new = root_new . find ( ' linkinfo ' )
if linkinfo_new == None :
raise oscerr . APIError ( ' link is not a really a link? ' )
if linkinfo_new . get ( ' error ' ) != None :
raise oscerr . APIError ( ' link target is broken ' )
2010-01-14 20:16:10 +01:00
if linkinfo_new . get ( ' srcmd5 ' ) == baserev :
2010-01-11 17:00:24 +01:00
print " Already up-to-date. "
2010-01-20 17:55:44 +01:00
p . unmark_frozen ( )
2010-01-11 17:00:24 +01:00
return
dir_new = { ' apiurl ' : p . apiurl , ' project ' : p . prjname , ' package ' : p . name }
dir_new [ ' srcmd5 ' ] = root_new . get ( ' srcmd5 ' )
dir_new [ ' entries ' ] = [ [ n . get ( ' name ' ) , n . get ( ' md5 ' ) ] for n in root_new . findall ( ' entry ' ) ]
2009-12-17 17:16:56 +01:00
2010-01-11 17:00:24 +01:00
dir_oldpatched = { ' apiurl ' : p . apiurl , ' project ' : p . prjname , ' package ' : p . name , ' srcmd5 ' : p . srcmd5 }
2010-01-14 20:16:10 +01:00
dir_oldpatched [ ' entries ' ] = [ [ f . name , f . md5 ] for f in p . filelist ]
2010-02-28 02:30:13 +01:00
2010-01-11 17:00:24 +01:00
query = { ' rev ' : linkinfo . srcmd5 }
u = makeurl ( p . apiurl , [ ' source ' , linkinfo . project , linkinfo . package ] , query = query )
f = http_GET ( u )
root_old = ET . parse ( f ) . getroot ( )
dir_old = { ' apiurl ' : p . apiurl , ' project ' : linkinfo . project , ' package ' : linkinfo . package , ' srcmd5 ' : linkinfo . srcmd5 }
dir_old [ ' entries ' ] = [ [ n . get ( ' name ' ) , n . get ( ' md5 ' ) ] for n in root_old . findall ( ' entry ' ) ]
# now do 3-way merge
entries_old = dict ( dir_old [ ' entries ' ] )
entries_oldpatched = dict ( dir_oldpatched [ ' entries ' ] )
entries_new = dict ( dir_new [ ' entries ' ] )
entries = { }
entries . update ( entries_old )
entries . update ( entries_oldpatched )
entries . update ( entries_new )
for name in sorted ( entries . keys ( ) ) :
md5_old = entries_old . get ( name , ' ' )
md5_new = entries_new . get ( name , ' ' )
md5_oldpatched = entries_oldpatched . get ( name , ' ' )
if md5_old == md5_new or md5_oldpatched == md5_new :
2010-01-14 20:16:10 +01:00
continue
2010-01-11 17:00:24 +01:00
if md5_old == md5_oldpatched :
if md5_new == ' ' :
2010-01-14 20:16:10 +01:00
print statfrmt ( ' D ' , name )
2010-01-11 17:00:24 +01:00
p . put_on_deletelist ( name )
2010-01-14 20:16:10 +01:00
os . unlink ( name )
2010-01-11 17:00:24 +01:00
else :
2010-01-14 20:16:10 +01:00
print statfrmt ( ' U ' , name )
2010-01-11 17:00:24 +01:00
self . download ( name , md5_new , dir_new , name )
2010-01-14 20:16:10 +01:00
continue
# need diff3 to resolve issue
if md5_oldpatched == ' ' :
open ( name , ' w ' ) . write ( ' ' )
os . rename ( name , name + ' .mine ' )
self . download ( name , md5_new , dir_new , name + ' .new ' )
2010-01-11 17:00:24 +01:00
self . download ( name , md5_old , dir_old , name + ' .old ' )
if binary_file ( name + ' .mine ' ) or binary_file ( name + ' .old ' ) or binary_file ( name + ' .new ' ) :
shutil . copy2 ( name + ' .new ' , name )
print statfrmt ( ' C ' , name )
p . put_on_conflictlist ( name )
continue
o = open ( name , ' wb ' )
2010-03-05 11:45:35 +01:00
code = subprocess . call ( [ ' diff3 ' , ' -m ' , ' -E ' ,
2010-01-11 17:00:24 +01:00
' -L ' , ' .mine ' , name + ' .mine ' ,
' -L ' , ' .old ' , name + ' .old ' ,
' -L ' , ' .new ' , name + ' .new ' ,
] , stdout = o )
if code == 0 :
print statfrmt ( ' G ' , name )
os . unlink ( name + ' .mine ' )
os . unlink ( name + ' .old ' )
os . unlink ( name + ' .new ' )
elif code == 1 :
print statfrmt ( ' C ' , name )
p . put_on_conflictlist ( name )
else :
print statfrmt ( ' ? ' , name )
p . put_on_conflictlist ( name )
p . write_deletelist ( )
p . write_conflictlist ( )
# store new linkrev
store_write_string ( p . absdir , ' _pulled ' , linkinfo_new . get ( ' srcmd5 ' ) )
2010-01-20 17:55:44 +01:00
p . unmark_frozen ( )
2010-01-11 17:00:24 +01:00
print
2010-01-14 20:16:10 +01:00
if len ( p . in_conflict ) :
2010-01-11 17:00:24 +01:00
print ' Please fix the conflicts (files marked with \' C \' above), '
print ' run \' osc resolved ... \' , and commit the changes '
2010-01-14 20:16:10 +01:00
print ' to update the link information. '
else :
print ' Please commit the changes to update the link information. '
2009-12-17 17:16:56 +01:00
2009-10-16 16:12:55 +02:00
@cmdln.option ( ' --create ' , action = ' store_true ' , default = False ,
help = ' create new gpg signing key for this project ' )
@cmdln.option ( ' --delete ' , action = ' store_true ' , default = False ,
help = ' delete the gpg signing key in this project ' )
2009-11-26 11:56:28 +01:00
@cmdln.option ( ' --notraverse ' , action = ' store_true ' , default = False ,
help = ' don \' traverse projects upwards to find key ' )
2009-10-16 16:12:55 +02:00
def do_signkey ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Manage Project Signing Key
2009-10-16 16:21:05 +02:00
osc signkey [ - - create | - - delete ] < PROJECT >
2009-11-26 11:56:28 +01:00
osc signkey [ - - notraverse ] < PROJECT >
2009-10-16 16:12:55 +02:00
This command is for managing gpg keys . It shows the public key
2009-10-20 16:30:15 +02:00
by default . There is no way to download or upload the private
2009-10-16 16:12:55 +02:00
part of a key by design .
However you can create a new own key . You may want to consider
to sign the public key with your own existing key .
If a project has no key , the key from upper level project will
be used ( eg . when dropping " KDE:KDE4:Community " key , the one from
" KDE:KDE4 " will be used ) .
2009-10-16 16:33:55 +02:00
WARNING : THE OLD KEY WILL NOT BE RESTORABLE WHEN USING DELETE OR CREATE
2009-10-16 16:12:55 +02:00
$ { cmd_usage }
$ { cmd_option_list }
"""
apiurl = conf . config [ ' apiurl ' ]
f = None
2009-11-26 11:56:28 +01:00
prj = None
if len ( args ) == 0 :
dir = os . getcwd ( )
if is_project_dir ( dir ) or is_package_dir ( dir ) :
prj = store_read_project ( dir )
apiurl = store_read_apiurl ( dir )
2009-10-16 16:12:55 +02:00
if len ( args ) == 1 :
prj = args [ 0 ]
2009-11-26 11:56:28 +01:00
if not prj :
2009-10-16 16:12:55 +02:00
raise oscerr . WrongArgs ( ' Please specify just the project ' )
if opts . create :
2009-10-20 16:30:15 +02:00
url = makeurl ( apiurl , [ ' source ' , prj ] , query = ' cmd=createkey ' )
f = http_POST ( url )
2009-10-16 16:12:55 +02:00
elif opts . delete :
2009-10-20 16:30:15 +02:00
url = makeurl ( apiurl , [ ' source ' , prj , " _pubkey " ] )
f = http_DELETE ( url )
2009-10-16 16:12:55 +02:00
else :
2009-11-26 11:56:28 +01:00
prjs = [ prj ]
for prj in prjs :
try :
url = makeurl ( apiurl , [ ' source ' , prj , " _pubkey " ] )
f = http_GET ( url )
break
2009-12-12 15:02:58 +01:00
except :
2009-11-26 11:56:28 +01:00
l = prj . rsplit ( ' : ' , 1 )
# try key from parent project
if not opts . notraverse and len ( l ) > 1 and l [ 1 ] :
print " %s has no key, trying %s " % ( prj , l [ 0 ] )
prjs . append ( l [ 0 ] )
else :
2009-12-12 15:02:58 +01:00
raise
2009-10-16 16:12:55 +02:00
2010-03-17 15:28:10 +01:00
while True :
2009-10-16 16:12:55 +02:00
buf = f . read ( 16384 )
2010-03-17 15:28:10 +01:00
if not buf :
break
sys . stdout . write ( buf )
2009-10-16 16:12:55 +02:00
2009-04-20 15:40:33 +02:00
@cmdln.option ( ' -m ' , ' --message ' ,
2009-04-22 16:44:17 +02:00
help = ' add MESSAGE to changes (not open an editor) ' )
@cmdln.option ( ' -e ' , ' --just-edit ' , action = ' store_true ' , default = False ,
2009-04-27 12:09:38 +02:00
help = ' just open changes (cannot be used with -m) ' )
2009-04-20 15:40:33 +02:00
def do_vc ( self , subcmd , opts , * args ) :
""" $ {cmd_name} : Edit the changes file
2009-04-22 16:44:17 +02:00
osc vc [ - m MESSAGE | - e ] [ filename [ . changes ] | path [ file_with_comment ] ]
2009-04-20 15:40:33 +02:00
If no < filename > is given , exactly one * . changes or * . spec file has to
be in the cwd or in path .
2010-01-02 12:25:37 +01:00
The email address used in . changes file is read from BuildService
2009-04-20 15:40:33 +02:00
instance , or should be defined in ~ / . oscrc
[ https : / / api . opensuse . org / ]
user = login
pass = password
email = user @defined.email
or can be specified via mailaddr environment variable .
$ { cmd_usage }
$ { cmd_option_list }
"""
2009-05-18 16:50:43 +02:00
2009-04-20 15:40:33 +02:00
from subprocess import Popen , PIPE
2009-04-22 16:44:17 +02:00
if not os . path . exists ( ' /usr/lib/build/vc ' ) :
2009-04-20 15:40:33 +02:00
print >> sys . stderr , ' Error: you need build.rpm with version 2009.04.17 or newer '
print >> sys . stderr , ' See http://download.opensuse.org/repositories/openSUSE:/Tools/ '
return 1
2009-04-22 16:44:17 +02:00
cmd_list = [ " /usr/lib/build/vc " , ]
2009-05-18 16:50:43 +02:00
2009-04-20 15:40:33 +02:00
if len ( args ) > 0 :
arg = args [ 0 ]
else :
arg = " "
# set user's email if no mailaddr exists
if not os . environ . has_key ( ' mailaddr ' ) :
2009-05-18 16:50:43 +02:00
2009-04-20 15:40:33 +02:00
if arg and is_package_dir ( arg ) :
apiurl = store_read_apiurl ( arg )
elif is_package_dir ( os . getcwd ( ) ) :
apiurl = store_read_apiurl ( os . getcwd ( ) )
else :
apiurl = conf . config [ ' apiurl ' ]
2009-04-22 19:38:14 +02:00
user = conf . get_apiurl_usr ( apiurl )
2009-04-20 15:40:33 +02:00
2009-11-18 16:03:49 +01:00
# work with all combinations of URL with or withouth the ending slash
2009-11-18 21:31:08 +01:00
if conf . config [ ' api_host_options ' ] [ apiurl ] . has_key ( ' email ' ) :
os . environ [ ' mailaddr ' ] = conf . config [ ' api_host_options ' ] [ apiurl ] [ ' email ' ]
2009-04-20 15:40:33 +02:00
else :
2009-11-10 01:56:52 +01:00
try :
2009-10-22 11:43:58 +02:00
os . environ [ ' mailaddr ' ] = get_user_data ( apiurl , user , ' email ' ) [ 0 ]
2009-12-20 20:42:54 +01:00
except Exception , e :
2009-10-22 11:43:58 +02:00
sys . exit ( ' %s \n get_user_data(email) failed. Try env mailaddr=.... \n ' % e )
2009-04-20 15:40:33 +02:00
if opts . message :
cmd_list . append ( " -m " )
2009-06-01 14:16:17 +02:00
cmd_list . append ( opts . message )
2009-04-20 15:40:33 +02:00
2009-04-22 16:44:17 +02:00
if opts . just_edit :
cmd_list . append ( " -e " )
2009-06-01 14:20:53 +02:00
if args :
cmd_list . extend ( args )
2009-04-20 15:40:33 +02:00
vc = Popen ( cmd_list )
vc . wait ( )
sys . exit ( vc . returncode )
2009-11-24 17:25:48 +01:00
@cmdln.option ( ' -f ' , ' --force ' , action = ' store_true ' ,
help = ' forces removal of entire package and its files ' )
def do_mv ( self , subcmd , opts , source , dest ) :
""" $ {cmd_name} : Move SOURCE file to DEST and keep it under version control
$ { cmd_usage }
$ { cmd_option_list }
"""
if not os . path . isfile ( source ) :
raise oscerr . WrongArgs ( " Source file `` %s ' ' does not exists " % source )
if not opts . force and os . path . isfile ( dest ) :
raise oscerr . WrongArgs ( " Dest file `` %s ' ' already exists " % dest )
if not is_package_dir ( ' . ' ) :
raise oscerr . NoWorkingCopy ( " Error: \" %s \" is not an osc working copy. " % os . path . abspath ( dir ) )
p = findpacs ( ' . ' ) [ 0 ]
os . rename ( source , dest )
self . do_add ( subcmd , opts , dest )
self . do_delete ( subcmd , opts , source )
2010-03-07 22:50:11 +01:00
@cmdln.option ( ' -d ' , ' --delete ' , action = ' store_true ' ,
help = ' delete option from config or reset option to the default) ' )
def do_config ( self , subcmd , opts , section , opt , * val ) :
""" $ {cmd_name} : get/set a config option
Examples :
osc config section option ( get current value )
osc config section option value ( set to value )
osc config section option - - delete ( delete option / reset to the default )
( section is either an apiurl or an alias or ' generic ' )
$ { cmd_usage }
$ { cmd_option_list }
"""
2010-03-09 12:22:04 +01:00
if len ( val ) and opts . delete :
raise oscerr . WrongOptions ( ' Sorry, --delete and the specification of a value argument are mutually exclusive ' )
2010-03-07 22:50:11 +01:00
opt , newval = conf . config_set_option ( section , opt , ' ' . join ( val ) , delete = opts . delete , update = False )
if newval is None and opts . delete :
print ' \' %s \' : \' %s \' got removed ' % ( section , opt )
elif newval is None :
print ' \' %s \' : \' %s \' is not set ' % ( section , opt )
else :
print ' \' %s \' : \' %s \' is set to \' %s \' ' % ( section , opt , newval )
2009-11-24 17:25:48 +01:00
2007-07-25 12:56:04 +02:00
# fini!
###############################################################################
2009-05-18 16:50:43 +02:00
2007-06-29 20:26:30 +02:00
# load subcommands plugged-in locally
2009-05-05 16:21:56 +02:00
plugin_dirs = [
2009-05-18 16:50:43 +02:00
' /usr/lib/osc-plugins ' ,
' /usr/local/lib/osc-plugins ' ,
2009-05-05 16:21:56 +02:00
' /var/lib/osc-plugins ' , # Kept for backward compatibility
os . path . expanduser ( ' ~/.osc-plugins ' ) ]
2007-06-29 20:26:30 +02:00
for plugin_dir in plugin_dirs :
if os . path . isdir ( plugin_dir ) :
for extfile in os . listdir ( plugin_dir ) :
if not extfile . endswith ( ' .py ' ) :
continue
exec open ( os . path . join ( plugin_dir , extfile ) )
2010-02-25 09:52:47 +01:00
# vim: sw=4 et
2006-04-20 16:26:50 +02:00