1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 17:26:15 +02:00
github.com_openSUSE_osc/osc/conf.py

934 lines
36 KiB
Python
Raw Normal View History

All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# Copyright (C) 2006-2009 Novell Inc. All rights reserved.
# This program is free software; it may be used, copied, modified
# and distributed under the terms of the GNU General Public Licence,
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# either version 2, or version 3 (at your option).
"""Read osc configuration and store it in a dictionary
This module reads and parses ~/.oscrc. The resulting configuration is stored
2009-10-20 16:30:15 +02:00
for later usage in a dictionary named 'config'.
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
The .oscrc is kept mode 0600, so that it is not publically readable.
2009-10-20 16:30:15 +02:00
This gives no real security for storing passwords.
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
If in doubt, use your favourite keyring.
2009-10-20 16:30:15 +02:00
Password is stored on ~/.oscrc as bz2 compressed and base64 encoded, so that is fairly
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
large and not to be recognized or remembered easily by an occasional spectator.
If information is missing, it asks the user questions.
After reading the config, urllib2 is initialized.
The configuration dictionary could look like this:
{'apisrv': 'https://api.opensuse.org/',
'user': 'joe',
'api_host_options': {'api.opensuse.org': {'user': 'joe', 'pass': 'secret'},
'apitest.opensuse.org': {'user': 'joe', 'pass': 'secret',
'http_headers':(('Host','api.suse.de'),
('User','faye'))},
'foo.opensuse.org': {'user': 'foo', 'pass': 'foo'}},
'build-cmd': '/usr/bin/build',
'build-root': '/abuild/oscbuild-%(repo)s-%(arch)s',
'packagecachedir': '/var/cache/osbuild',
'su-wrapper': 'sudo',
}
"""
2009-10-29 18:27:20 +01:00
import base64
import cookielib
import httplib
import os
import re
import sys
import StringIO
2011-07-15 20:10:45 +02:00
import urllib
import urllib2
import urlparse
2011-07-15 20:10:45 +02:00
import OscConfigParser
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
from osc import oscerr
from oscsslexcp import NoSecureSSLError
GENERIC_KEYRING = False
GNOME_KEYRING = False
try:
import keyring
GENERIC_KEYRING = True
except:
2009-10-20 16:30:15 +02:00
try:
import gobject
gobject.set_application_name('osc')
import gnomekeyring
if os.environ['GNOME_DESKTOP_SESSION_ID']:
# otherwise gnome keyring bindings spit out errors, when you have
# it installed, but you are not under gnome
# (even though hundreds of gnome-keyring daemons got started in parallel)
# another option would be to support kwallet here
GNOME_KEYRING = gnomekeyring.is_available()
except:
pass
def _get_processors():
"""
get number of processors (online) based on
SC_NPROCESSORS_ONLN (returns 1 if config name does not exist).
"""
try:
return os.sysconf('SC_NPROCESSORS_ONLN')
except ValueError, e:
return 1
DEFAULTS = {'apiurl': 'https://api.opensuse.org',
'user': 'your_username',
'pass': 'your_password',
'passx': '',
'packagecachedir': '/var/tmp/osbuild-packagecache',
'su-wrapper': 'sudo',
# build type settings
'build-cmd': '/usr/bin/build',
'build-type': '', # may be empty for chroot, kvm or xen
'build-root': '/var/tmp/build-root',
'build-uid': '', # use the default provided by build
'build-device': '', # required for VM builds
'build-memory': '', # required for VM builds
'build-swap': '', # optional for VM builds
'build-vmdisk-rootsize': '', # optional for VM builds
'build-vmdisk-swapsize': '', # optional for VM builds
2012-02-04 17:02:18 +01:00
'build-vmdisk-filesystem': '', # optional for VM builds
'build-jobs': _get_processors(),
'builtin_signature_check': '1', # by default use builtin check for verify pkgs
'icecream': '0',
'debug': '0',
'http_debug': '0',
'http_full_debug': '0',
'http_retries': '3',
'verbose': '1',
'traceback': '0',
'post_mortem': '0',
'use_keyring': '1',
'gnome_keyring': '1',
'cookiejar': '~/.osc_cookiejar',
# fallback for osc build option --no-verify
'no_verify': '0',
# enable project tracking by default
'do_package_tracking': '1',
# default for osc build
'extra-pkgs': '',
# default repository
'build_repository': 'openSUSE_Factory',
# default project for branch or bco
'getpac_default_project': 'openSUSE:Factory',
# alternate filesystem layout: have multiple subdirs, where colons were.
'checkout_no_colon': '0',
# change filesystem layout: avoid checkout from within a proj or package dir.
'checkout_rooted': '0',
# local files to ignore with status, addremove, ....
'exclude_glob': '.osc CVS .svn .* _linkerror *~ #*# *.orig *.bak *.changes.vctmp.*',
# whether to keep passwords in plaintext.
'plaintext_passwd': '1',
# limit the age of requests shown with 'osc req list'.
# this is a default only, can be overridden by 'osc req list -D NNN'
# Use 0 for unlimted.
'request_list_days': 0,
# check for unversioned/removed files before commit
'check_filelist': '1',
# check for pending requests after executing an action (e.g. checkout, update, commit)
'check_for_request_on_action': '0',
# what to do with the source package if the submitrequest has been accepted
'submitrequest_on_accept_action': '',
'request_show_interactive': '0',
'submitrequest_accepted_template': '',
'submitrequest_declined_template': '',
'linkcontrol': '0',
'include_request_from_project': '1',
'local_service_run': '1',
# Maintenance defaults to OBS instance defaults
'maintained_attribute': 'OBS:Maintained',
'maintenance_attribute': 'OBS:MaintenanceProject',
'maintained_update_project_attribute': 'OBS:UpdateProject',
'show_download_progress': '0',
}
# being global to this module, this dict can be accessed from outside
# it will hold the parsed configuration
config = DEFAULTS.copy()
boolean_opts = ['debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist', 'plaintext_passwd',
'checkout_no_colon', 'checkout_rooted', 'check_for_request_on_action', 'linkcontrol', 'show_download_progress', 'request_show_interactive',
'use_keyring', 'gnome_keyring', 'no_verify', 'builtin_signature_check', 'http_full_debug', 'include_request_from_project',
'local_service_run']
api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj']
new_conf_template = """
[general]
# URL to access API server, e.g. %(apiurl)s
# you also need a section [%(apiurl)s] with the credentials
apiurl = %(apiurl)s
# Downloaded packages are cached here. Must be writable by you.
#packagecachedir = %(packagecachedir)s
# Wrapper to call build as root (sudo, su -, ...)
#su-wrapper = %(su-wrapper)s
# rootdir to setup the chroot environment
# can contain %%(repo)s, %%(arch)s, %%(project)s, %%(package)s and %%(apihost)s (apihost is the hostname
# extracted from currently used apiurl) for replacement, e.g.
# /srv/oscbuild/%%(repo)s-%%(arch)s or
# /srv/oscbuild/%%(repo)s-%%(arch)s-%%(project)s-%%(package)s
#build-root = %(build-root)s
# compile with N jobs (default: "getconf _NPROCESSORS_ONLN")
#build-jobs = N
# build-type to use - values can be (depending on the capabilities of the 'build' script)
# empty - chroot build
# kvm - kvm VM build (needs build-device, build-swap, build-memory)
# xen - xen VM build (needs build-device, build-swap, build-memory)
# experimental:
# qemu - qemu VM build
# lxc - lxc build
#build-type =
# build-device is the disk-image file to use as root for VM builds
# e.g. /var/tmp/FILE.root
#build-device = /var/tmp/FILE.root
# build-swap is the disk-image to use as swap for VM builds
# e.g. /var/tmp/FILE.swap
#build-swap = /var/tmp/FILE.swap
# build-memory is the amount of memory used in the VM
# value in MB - e.g. 512
#build-memory = 512
# build-vmdisk-rootsize is the size of the disk-image used as root in a VM build
# values in MB - e.g. 4096
#build-vmdisk-rootsize = 4096
# build-vmdisk-swapsize is the size of the disk-image used as swap in a VM build
# values in MB - e.g. 1024
#build-vmdisk-swapsize = 1024
2012-02-04 17:02:18 +01:00
# build-vmdisk-filesystem is the file system type of the disk-image used in a VM build
# values are ext3(default) ext4 xfs reiserfs btrfs
#build-vmdisk-filesystem = ext4
# Numeric uid:gid to assign to the "abuild" user in the build-root
# or "caller" to use the current users uid:gid
# This is convenient when sharing the buildroot with ordinary userids
# on the host.
# This should not be 0
2010-02-28 02:30:13 +01:00
# build-uid =
# extra packages to install when building packages locally (osc build)
# this corresponds to osc build's -x option and can be overridden with that
# -x '' can also be given on the command line to override this setting, or
# you can have an empty setting here.
#extra-pkgs = vim gdb strace
# build platform is used if the platform argument is omitted to osc build
#build_repository = %(build_repository)s
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# default project for getpac or bco
#getpac_default_project = %(getpac_default_project)s
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# alternate filesystem layout: have multiple subdirs, where colons were.
#checkout_no_colon = %(checkout_no_colon)s
# change filesystem layout: avoid checkout within a project or package dir.
#checkout_rooted = %(checkout_rooted)s
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# local files to ignore with status, addremove, ....
#exclude_glob = %(exclude_glob)s
# keep passwords in plaintext.
# Set to 0 to obfuscate passwords. It's no real security, just
# prevents most people from remembering your password if they watch
# you editing this file.
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
#plaintext_passwd = %(plaintext_passwd)s
# limit the age of requests shown with 'osc req list'.
# this is a default only, can be overridden by 'osc req list -D NNN'
# Use 0 for unlimted.
#request_list_days = %(request_list_days)s
# show info useful for debugging
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
#debug = 1
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# show HTTP traffic useful for debugging
#http_debug = 1
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# number of retries on HTTP transfer
#http_retries = 3
2010-08-12 21:34:08 +02:00
# Skip signature verification of packages used for build.
#no_verify = 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
# jump into the debugger in case of errors
#post_mortem = 1
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +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
# print call traces in case of errors
#traceback = 1
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# use KDE/Gnome/MacOS/Windows keyring for credentials if available
#use_keyring = 1
# check for unversioned/removed files before commit
#check_filelist = 1
# check for pending requests after executing an action (e.g. checkout, update, commit)
#check_for_request_on_action = 0
# what to do with the source package if the submitrequest has been accepted. If
# nothing is specified the API default is used
#submitrequest_on_accept_action = cleanup|update|noupdate
# template for an accepted submitrequest
#submitrequest_accepted_template = Hi %%(who)s,\\n
# thanks for working on:\\t%%(tgt_project)s/%%(tgt_package)s.
# SR %%(reqid)s has been accepted.\\n\\nYour maintainers
# template for a declined submitrequest
#submitrequest_declined_template = Hi %%(who)s,\\n
# sorry your SR %%(reqid)s (request type: %%(type)s) for
# %%(tgt_project)s/%%(tgt_package)s has been declined because...
#review requests interactively (default: off)
#request_show_review = 1
[%(apiurl)s]
user = %(user)s
pass = %(pass)s
# set aliases for this apiurl
# aliases = foo, bar
# email used in .changes, unless the one from osc meta prj <user> will be used
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# email =
# additional headers to pass to a request, e.g. for special authentication
#http_headers = Host: foofoobar,
# User: mumblegack
# Plain text password
#pass =
# Force using of keyring for this API
#keyring = 1
"""
account_not_configured_text = """
Your user account / password are not configured yet.
You will be asked for them below, and they will be stored in
%s for future use.
"""
config_incomplete_text = """
Your configuration file %s is not complete.
Make sure that it has a [general] section.
(You can copy&paste the below. Some commented defaults are shown.)
"""
config_missing_apiurl_text = """
the apiurl \'%s\' does not exist in the config file. Please enter
your credentials for this apiurl.
"""
cookiejar = None
def parse_apisrv_url(scheme, apisrv):
if apisrv.startswith('http://') or apisrv.startswith('https://'):
return urlparse.urlsplit(apisrv)[0:2]
elif scheme != None:
# the split/join is needed to get a proper url (e.g. without a trailing slash)
return urlparse.urlsplit(urljoin(scheme, apisrv))[0:2]
else:
msg = 'invalid apiurl \'%s\' (specify the protocol (http:// or https://))' % apisrv
raise urllib2.URLError(msg)
def urljoin(scheme, apisrv):
return '://'.join([scheme, apisrv])
def is_known_apiurl(url):
"""returns true if url is a known apiurl"""
apiurl = urljoin(*parse_apisrv_url(None, url))
return apiurl in config['api_host_options']
def get_apiurl_api_host_options(apiurl):
"""
Returns all apihost specific options for the given apiurl, None if
no such specific optiosn exist.
"""
# FIXME: in A Better World (tm) there was a config object which
# knows this instead of having to extract it from a url where it
# had been mingled into before. But this works fine for now.
apiurl = urljoin(*parse_apisrv_url(None, apiurl))
if is_known_apiurl(apiurl):
return config['api_host_options'][apiurl]
raise oscerr.ConfigMissingApiurl('missing credentials for apiurl: \'%s\'' % apiurl,
'', apiurl)
def get_apiurl_usr(apiurl):
"""
returns the user for this host - if this host does not exist in the
internal api_host_options the default user is returned.
"""
# FIXME: maybe there should be defaults not just for the user but
# for all apihost specific options. The ConfigParser class
# actually even does this but for some reason we don't use it
# (yet?).
try:
return get_apiurl_api_host_options(apiurl)['user']
except KeyError:
print >>sys.stderr, 'no specific section found in config file for host of [\'%s\'] - using default user: \'%s\'' \
% (apiurl, config['user'])
return config['user']
# workaround m2crypto issue:
# if multiple SSL.Context objects are created
# m2crypto only uses the last object which was created.
# So we need to build a new opener everytime we switch the
# apiurl (because different apiurls may have different
# cafile/capath locations)
def _build_opener(url):
from osc.core import __version__
global config
apiurl = urljoin(*parse_apisrv_url(None, url))
if 'last_opener' not in _build_opener.__dict__:
_build_opener.last_opener = (None, None)
if apiurl == _build_opener.last_opener[0]:
return _build_opener.last_opener[1]
2011-07-15 20:10:45 +02:00
# respect no_proxy env variable
if urllib.proxy_bypass(apiurl):
# initialize with empty dict
proxyhandler = urllib2.ProxyHandler({})
else:
# read proxies from env
proxyhandler = urllib2.ProxyHandler()
# workaround for http://bugs.python.org/issue9639
authhandler_class = urllib2.HTTPBasicAuthHandler
if sys.version_info >= (2, 6, 6) and sys.version_info < (2, 7, 1) \
2010-08-26 17:38:47 +02:00
and not 'reset_retry_count' in dir(urllib2.HTTPBasicAuthHandler):
print >>sys.stderr, 'warning: your urllib2 version seems to be broken. ' \
'Using a workaround for http://bugs.python.org/issue9639'
class OscHTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler):
def http_error_401(self, *args):
response = urllib2.HTTPBasicAuthHandler.http_error_401(self, *args)
self.retried = 0
return response
def http_error_404(self, *args):
self.retried = 0
return None
authhandler_class = OscHTTPBasicAuthHandler
elif sys.version_info >= (2, 6, 6) and sys.version_info < (2, 7, 1):
class OscHTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler):
def http_error_404(self, *args):
self.reset_retry_count()
return None
authhandler_class = OscHTTPBasicAuthHandler
elif sys.version_info >= (2, 6, 5) and sys.version_info < (2, 6, 6):
# workaround for broken urllib2 in python 2.6.5: wrong credentials
# lead to an infinite recursion
class OscHTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler):
def retry_http_basic_auth(self, host, req, realm):
# don't retry if auth failed
if req.get_header(self.auth_header, None) is not None:
return None
return urllib2.HTTPBasicAuthHandler.retry_http_basic_auth(self, host, req, realm)
authhandler_class = OscHTTPBasicAuthHandler
options = config['api_host_options'][apiurl]
# with None as first argument, it will always use this username/password
# combination for urls for which arg2 (apisrv) is a super-url
authhandler = authhandler_class( \
urllib2.HTTPPasswordMgrWithDefaultRealm())
authhandler.add_password(None, apiurl, options['user'], options['pass'])
if options['sslcertck']:
try:
import oscssl
from M2Crypto import m2urllib2
except ImportError, e:
print e
raise NoSecureSSLError('M2Crypto is needed to access %s in a secure way.\nPlease install python-m2crypto.' % apiurl)
cafile = options.get('cafile', None)
capath = options.get('capath', None)
if not cafile and not capath:
for i in ['/etc/pki/tls/cert.pem', '/etc/ssl/certs']:
if os.path.isfile(i):
cafile = i
break
elif os.path.isdir(i):
capath = i
break
ctx = oscssl.mySSLContext()
if ctx.load_verify_locations(capath=capath, cafile=cafile) != 1:
raise Exception('No CA certificates found')
opener = m2urllib2.build_opener(ctx, oscssl.myHTTPSHandler(ssl_context=ctx, appname='osc'), urllib2.HTTPCookieProcessor(cookiejar), authhandler, proxyhandler)
else:
print >>sys.stderr, "WARNING: SSL certificate checks disabled. Connection is insecure!\n"
2011-07-15 20:10:45 +02:00
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar), authhandler, proxyhandler)
opener.addheaders = [('User-agent', 'osc/%s' % __version__)]
_build_opener.last_opener = (apiurl, opener)
return opener
def init_basicauth(config):
"""initialize urllib2 with the credentials for Basic Authentication"""
def filterhdrs(meth, ishdr, *hdrs):
# this is so ugly but httplib doesn't use
# a logger object or such
def new_method(*args, **kwargs):
stdout = sys.stdout
sys.stdout = StringIO.StringIO()
meth(*args, **kwargs)
hdr = sys.stdout.getvalue()
sys.stdout = stdout
for i in hdrs:
if ishdr:
hdr = re.sub(r'%s:[^\\r]*\\r\\n' % i, '', hdr)
else:
hdr = re.sub(i, '', hdr)
sys.stdout.write(hdr)
new_method.__name__ = meth.__name__
return new_method
if config['http_debug'] and not config['http_full_debug']:
httplib.HTTPConnection.send = filterhdrs(httplib.HTTPConnection.send, True, 'Cookie', 'Authorization')
httplib.HTTPResponse.begin = filterhdrs(httplib.HTTPResponse.begin, False, 'header: Set-Cookie.*\n')
if sys.version_info < (2, 6):
# HTTPS proxy is not supported in old urllib2. It only leads to an error
# or, at best, a warning.
if 'https_proxy' in os.environ:
del os.environ['https_proxy']
if 'HTTPS_PROXY' in os.environ:
del os.environ['HTTPS_PROXY']
if config['http_debug']:
# brute force
def urllib2_debug_init(self, debuglevel=0):
self._debuglevel = 1
urllib2.AbstractHTTPHandler.__init__ = urllib2_debug_init
cookie_file = os.path.expanduser(config['cookiejar'])
global cookiejar
cookiejar = cookielib.LWPCookieJar(cookie_file)
try:
cookiejar.load(ignore_discard=True)
except IOError:
try:
open(cookie_file, 'w').close()
os.chmod(cookie_file, 0600)
except:
#print 'Unable to create cookiejar file: \'%s\'. Using RAM-based cookies.' % cookie_file
cookiejar = cookielib.CookieJar()
def get_configParser(conffile=None, force_read=False):
"""
Returns an ConfigParser() object. After its first invocation the
ConfigParser object is stored in a method attribute and this attribute
is returned unless you pass force_read=True.
"""
conffile = conffile or os.environ.get('OSC_CONFIG', '~/.oscrc')
conffile = os.path.expanduser(conffile)
if 'conffile' not in get_configParser.__dict__:
get_configParser.conffile = conffile
if force_read or 'cp' not in get_configParser.__dict__ or conffile != get_configParser.conffile:
get_configParser.cp = OscConfigParser.OscConfigParser(DEFAULTS)
get_configParser.cp.read(conffile)
get_configParser.conffile = conffile
return get_configParser.cp
def write_config(fname, cp):
"""write new configfile in a safe way"""
if os.path.exists(fname) and not os.path.isfile(fname):
# only write to a regular file
return
with open(fname + '.new', 'w') as f:
cp.write(f, comments=True)
try:
os.rename(fname + '.new', fname)
os.chmod(fname, 0600)
except:
if os.path.exists(fname + '.new'):
os.unlink(fname + '.new')
raise
def config_set_option(section, opt, val=None, delete=False, update=True, **kwargs):
"""
Sets a config option. If val is not specified the current/default value is
returned. If val is specified, opt is set to val and the new value is returned.
If an option was modified get_config is called with **kwargs unless update is set
to False (override_conffile defaults to config['conffile']).
If val is not specified and delete is True then the option is removed from the
config/reset to the default value.
"""
cp = get_configParser(config['conffile'])
# don't allow "internal" options
general_opts = [i for i in DEFAULTS.keys() if not i in ['user', 'pass', 'passx']]
2010-06-23 14:20:56 +02:00
if section != 'general':
section = config['apiurl_aliases'].get(section, section)
scheme, host = \
parse_apisrv_url(config.get('scheme', 'https'), section)
section = urljoin(scheme, host)
sections = {}
for url in cp.sections():
if url == 'general':
sections[url] = url
else:
scheme, host = \
parse_apisrv_url(config.get('scheme', 'https'), url)
apiurl = urljoin(scheme, host)
sections[apiurl] = url
2010-03-08 14:09:15 +01:00
section = sections.get(section.rstrip('/'), section)
if not section in cp.sections():
raise oscerr.ConfigError('unknown section \'%s\'' % section, config['conffile'])
if section == 'general' and not opt in general_opts or \
section != 'general' and not opt in api_host_options:
raise oscerr.ConfigError('unknown config option \'%s\'' % opt, config['conffile'])
run = False
if val:
cp.set(section, opt, val)
write_config(config['conffile'], cp)
run = True
elif delete and cp.has_option(section, opt):
cp.remove_option(section, opt)
write_config(config['conffile'], cp)
run = True
if run and update:
kw = {'override_conffile': config['conffile'],
'override_no_keyring': config['use_keyring'],
'override_no_gnome_keyring': config['gnome_keyring']}
kw.update(kwargs)
get_config(**kw)
if cp.has_option(section, opt):
return (opt, cp.get(section, opt, raw=True))
return (opt, None)
def write_initial_config(conffile, entries, custom_template=''):
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
"""
write osc's intial configuration file. entries is a dict which contains values
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
for the config file (e.g. { 'user' : 'username', 'pass' : 'password' } ).
custom_template is an optional configuration template.
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_template = custom_template or new_conf_template
config = DEFAULTS.copy()
config.update(entries)
2010-02-25 14:13:02 +01:00
# at this point use_keyring and gnome_keyring are str objects
if config['use_keyring'] == '1' and GENERIC_KEYRING:
protocol, host = \
parse_apisrv_url(None, config['apiurl'])
keyring.set_password(host, config['user'], config['pass'])
config['pass'] = ''
config['passx'] = ''
2010-02-25 14:13:02 +01:00
elif config['gnome_keyring'] == '1' and GNOME_KEYRING:
protocol, host = \
parse_apisrv_url(None, config['apiurl'])
gnomekeyring.set_network_password_sync(
user=config['user'],
password=config['pass'],
protocol=protocol,
server=host)
config['user'] = ''
config['pass'] = ''
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
config['passx'] = ''
if not config['plaintext_passwd']:
config['pass'] = ''
else:
config['passx'] = base64.b64encode(config['pass'].encode('bz2'))
sio = StringIO.StringIO(conf_template.strip() % config)
cp = OscConfigParser.OscConfigParser(DEFAULTS)
cp.readfp(sio)
write_config(conffile, cp)
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 add_section(filename, url, user, passwd):
"""
Add a section to config file for new api url.
"""
global config
cp = get_configParser(filename)
try:
cp.add_section(url)
except OscConfigParser.ConfigParser.DuplicateSectionError:
# Section might have existed, but was empty
pass
if config['use_keyring'] and GENERIC_KEYRING:
protocol, host = parse_apisrv_url(None, url)
keyring.set_password(host, user, passwd)
cp.set(url, 'keyring', '1')
cp.set(url, 'user', user)
cp.remove_option(url, 'pass')
cp.remove_option(url, 'passx')
elif config['gnome_keyring'] and GNOME_KEYRING:
protocol, host = parse_apisrv_url(None, url)
gnomekeyring.set_network_password_sync(
user=user,
password=passwd,
protocol=protocol,
server=host)
cp.set(url, 'keyring', '1')
cp.remove_option(url, 'pass')
cp.remove_option(url, 'passx')
else:
cp.set(url, 'user', user)
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
if not config['plaintext_passwd']:
cp.remove_option(url, 'pass')
cp.set(url, 'passx', base64.b64encode(passwd.encode('bz2')))
else:
cp.remove_option(url, 'passx')
cp.set(url, 'pass', passwd)
write_config(filename, cp)
def get_config(override_conffile=None,
override_apiurl=None,
override_debug=None,
override_http_debug=None,
override_http_full_debug=None,
override_traceback=None,
override_post_mortem=None,
override_no_keyring=None,
override_no_gnome_keyring=None,
override_verbose=None):
"""do the actual work (see module documentation)"""
global config
conffile = override_conffile or os.environ.get('OSC_CONFIG', '~/.oscrc')
conffile = os.path.expanduser(conffile)
if not os.path.exists(conffile):
raise oscerr.NoConfigfile(conffile, \
account_not_configured_text % conffile)
# okay, we made sure that .oscrc exists
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# make sure it is not world readable, it may contain a password.
os.chmod(conffile, 0600)
cp = get_configParser(conffile)
if not cp.has_section('general'):
# FIXME: it might be sufficient to just assume defaults?
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 = config_incomplete_text % conffile
msg += new_conf_template % DEFAULTS
raise oscerr.ConfigError(msg, conffile)
config = dict(cp.items('general', raw=1))
config['conffile'] = conffile
for i in boolean_opts:
try:
config[i] = cp.getboolean('general', i)
except ValueError, e:
raise oscerr.ConfigError('cannot parse \'%s\' setting: ' % i + str(e), conffile)
config['packagecachedir'] = os.path.expanduser(config['packagecachedir'])
config['exclude_glob'] = config['exclude_glob'].split()
re_clist = re.compile('[, ]+')
config['extra-pkgs'] = [i.strip() for i in re_clist.split(config['extra-pkgs'].strip()) if i]
# collect the usernames, passwords and additional options for each api host
api_host_options = {}
# Regexp to split extra http headers into a dictionary
# the text to be matched looks essentially looks this:
# "Attribute1: value1, Attribute2: value2, ..."
# there may be arbitray leading and intermitting whitespace.
# the following regexp does _not_ support quoted commas within the value.
http_header_regexp = re.compile(r"\s*(.*?)\s*:\s*(.*?)\s*(?:,\s*|\Z)")
# override values which we were called with
# This needs to be done before processing API sections as it might be already used there
if override_no_keyring:
config['use_keyring'] = False
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
if override_no_gnome_keyring:
config['gnome_keyring'] = False
aliases = {}
for url in [x for x in cp.sections() if x != 'general']:
# backward compatiblity
scheme, host = parse_apisrv_url(config.get('scheme', 'https'), url)
apiurl = urljoin(scheme, host)
2009-09-06 23:19:40 +02:00
user = None
if config['use_keyring'] and GENERIC_KEYRING:
try:
# Read from keyring lib if available
2009-09-06 23:19:40 +02:00
user = cp.get(url, 'user', raw=True)
password = keyring.get_password(host, user)
except:
# Fallback to file based auth.
pass
elif config['gnome_keyring'] and GNOME_KEYRING:
# Read from gnome keyring if available
try:
gk_data = gnomekeyring.find_network_password_sync(protocol=scheme, server=host)
password = gk_data[0]['password']
user = gk_data[0]['user']
except gnomekeyring.NoMatchError:
# Fallback to file based auth.
pass
if not user is None and len(user) == 0:
user = None
2010-12-18 03:39:19 +01:00
print >>sys.stderr, 'Warning: blank user in the keyring for the ' \
'apiurl %s.\nPlease fix your keyring entry.'
# Read credentials from config
if user is None:
#FIXME: this could actually be the ideal spot to take defaults
#from the general section.
user = cp.get(url, 'user', raw=True) # need to set raw to prevent '%' expansion
password = cp.get(url, 'pass', raw=True) # especially on password!
try:
passwordx = cp.get(url, 'passx', raw=True).decode('base64').decode('bz2') # especially on password!
except:
passwordx = ''
if password == None or password == 'your_password':
password = ''
2010-12-18 03:39:19 +01:00
if user is None or user == '':
raise oscerr.ConfigError('user is blank for %s, please delete of complete the "user=" entry in %s.' % (apiurl, config['conffile']), config['conffile'])
if config['plaintext_passwd'] and passwordx or not config['plaintext_passwd'] and password:
2011-05-23 16:34:04 +02:00
if config['plaintext_passwd']:
if password != passwordx:
print >>sys.stderr, '%s: rewriting from encoded pass to plain pass' % url
add_section(conffile, url, user, passwordx)
password = passwordx
2011-05-23 16:34:04 +02:00
else:
if password != passwordx:
print >>sys.stderr, '%s: rewriting from plain pass to encoded pass' % url
add_section(conffile, url, user, password)
if not config['plaintext_passwd']:
password = passwordx
if cp.has_option(url, 'http_headers'):
http_headers = cp.get(url, 'http_headers')
http_headers = http_header_regexp.findall(http_headers)
else:
http_headers = []
if cp.has_option(url, 'aliases'):
for i in cp.get(url, 'aliases').split(','):
key = i.strip()
if key == '':
continue
if key in aliases:
msg = 'duplicate alias entry: \'%s\' is already used for another apiurl' % key
raise oscerr.ConfigError(msg, conffile)
aliases[key] = url
api_host_options[apiurl] = {'user': user,
'pass': password,
'http_headers': http_headers}
optional = ('email', 'sslcertck', 'cafile', 'capath')
for key in optional:
if cp.has_option(url, key):
2009-10-06 19:10:31 +02:00
if key == 'sslcertck':
api_host_options[apiurl][key] = cp.getboolean(url, key)
else:
api_host_options[apiurl][key] = cp.get(url, key)
if not 'sslcertck' in api_host_options[apiurl]:
2009-10-06 19:10:31 +02:00
api_host_options[apiurl]['sslcertck'] = True
2010-09-01 12:04:46 +02:00
if scheme == 'http':
api_host_options[apiurl]['sslcertck'] = False
2010-02-24 20:02:52 +01:00
if cp.has_option(url, 'trusted_prj'):
2010-06-23 14:40:55 +02:00
api_host_options[apiurl]['trusted_prj'] = cp.get(url, 'trusted_prj').split(' ')
2010-02-24 20:02:52 +01:00
else:
api_host_options[apiurl]['trusted_prj'] = []
2009-11-11 15:48:25 +01:00
# add the auth data we collected to the config dict
config['api_host_options'] = api_host_options
config['apiurl_aliases'] = aliases
apiurl = aliases.get(config['apiurl'], config['apiurl'])
config['apiurl'] = urljoin(*parse_apisrv_url(None, apiurl))
# backward compatibility
if key in config:
apisrv = config['apisrv'].lstrip('http://')
apisrv = apisrv.lstrip('https://')
scheme = config.get('scheme', 'https')
config['apiurl'] = urljoin(scheme, apisrv)
if 'apisrc' in config or 'scheme' in config:
print >>sys.stderr, 'Warning: Use of the \'scheme\' or \'apisrv\' in ~/.oscrc is deprecated!\n' \
'Warning: See README for migration details.'
if 'build_platform' in config:
print >>sys.stderr, 'Warning: Use of \'build_platform\' config option is deprecated! (use \'build_repository\' instead)'
config['build_repository'] = config['build_platform']
config['verbose'] = int(config['verbose'])
# override values which we were called with
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
if override_verbose:
config['verbose'] = override_verbose + 1
if override_debug:
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
config['debug'] = override_debug
if override_http_debug:
config['http_debug'] = override_http_debug
if override_http_full_debug:
config['http_debug'] = override_http_full_debug or config['http_debug']
config['http_full_debug'] = override_http_full_debug
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 override_traceback:
config['traceback'] = override_traceback
if override_post_mortem:
config['post_mortem'] = override_post_mortem
if override_apiurl:
apiurl = aliases.get(override_apiurl, override_apiurl)
# check if apiurl is a valid url
config['apiurl'] = urljoin(*parse_apisrv_url(None, apiurl))
All in one go. 0.121.jw02 - made rresults an alias for results. python decorators are a strange concept... - asserting that ~/.oscrc remains mode 0600 - no more plain text passwords in ~/.oscrc, we store now as bz2+base64 - added verbosity control -v -q. To be used in guess_proj_pack() - added 'll' and 'ls -l' as shorthand to 'list -v' - started to change to explicit dual license GPLv2 or GPLv3 to conform to Novell policy. - added revision parameter to show_upstream_srcmd5(), so that it can be used in do_cat later. - allowed both integer and srcmd5 revisions in meta_get_filelist() - added 'lL', 'LL': allowed -e and -v together in do_list(). Was an internal error before. - added cat -e, to cat a file through a link. 'cat -e -r 3' expands through the third revision of the _link. - added subcmd bco as alias for branch -c - added default project to branch subcommand. .oscrc:branch_project = OpenSUSE:Factory - added primitive experimental support for .oscrc:checkout_no_colon = 1 - suggest using svn when .svn found. - alias submitpac submitrequest - osc bco now continues to checkout after branch target exists error. - added .oscrc:plaintext_passwd=1 for backwards compatibility - moved core.py:exclude_stuff to .oscrc:exclude_glob and expand it to catch *.orig etc. - allowed req as alias for request. - bugfix get_request_list: use 'or' with multiple states, not 'and'. - added osc req list -s all; a shorthand for enumerating all states - osc req list no longer confuses creator with approver. - osc req list -D nnn limit to requests nnn days old. - osc req list now also shows requests from the the given package, not only to. - improved help texts with repairlink to point to osc resolved. - improved passx code when creating oscrc. - osc sr -l is now a shortcut for 'osc req list -M -a -t submit -D 0'
2009-08-20 21:28:05 +02:00
# XXX unless config['user'] goes away (and is replaced with a handy function, or
# config becomes an object, even better), set the global 'user' here as well,
# provided that there _are_ credentials for the chosen apiurl:
try:
config['user'] = get_apiurl_usr(config['apiurl'])
except oscerr.ConfigMissingApiurl, e:
e.msg = config_missing_apiurl_text % config['apiurl']
e.file = conffile
raise e
# finally, initialize urllib2 for to use the credentials for Basic Authentication
init_basicauth(config)
# vim: sw=4 et