Univention Bugzilla – Attachment 5196 Details for
Bug 31199
System info does not handle errors gracefully
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Upload fails gracefully
31199.patch (text/plain), 5.88 KB, created by
Dirk Wiesenthal
on 2013-04-25 21:28:24 CEST
(
hide
)
Description:
Upload fails gracefully
Filename:
MIME Type:
Creator:
Dirk Wiesenthal
Created:
2013-04-25 21:28:24 CEST
Size:
5.88 KB
patch
obsolete
>Index: debian/control >=================================================================== >--- debian/control (Revision 40130) >+++ debian/control (Arbeitskopie) >@@ -8,6 +8,7 @@ > univention-management-console-dev, > python-all > Standards-Version: 3.8.2 >+XS-Python-Version: 2.6 > > Package: univention-system-info > Architecture: all >Index: umc/js/sysinfo.js >=================================================================== >--- umc/js/sysinfo.js (Revision 40130) >+++ umc/js/sysinfo.js (Arbeitskopie) >@@ -33,7 +33,9 @@ > "dojo/_base/lang", > "dojo/_base/array", > "dojo/topic", >+ "dojo/Deferred", > "umc/tools", >+ "umc/dialog", > "umc/widgets/Module", > "umc/widgets/Wizard", > "umc/widgets/StandbyMixin", >@@ -43,7 +45,7 @@ > "umc/widgets/TextArea", > "umc/widgets/CheckBox", > "umc/i18n!umc/modules/sysinfo" >-], function(declare, lang, array, topic, tools, Module, Wizard, StandbyMixin, ComboBox, TextBox, Text, TextArea, CheckBox, _) { >+], function(declare, lang, array, topic, Deferred, tools, dialog, Module, Wizard, StandbyMixin, ComboBox, TextBox, Text, TextArea, CheckBox, _) { > > var SysinfoWizard = declare("umc.modules.sysinfo.Wizard", [ Wizard, StandbyMixin ], { > >@@ -86,7 +88,7 @@ > }, { > name: 'support', > headerText: _('Support information'), >- helpText: _(''), >+ helpText: '', > widgets: [{ > type: Text, > name: 'firstText', >@@ -107,7 +109,7 @@ > }, { > name: 'collect', > headerText: _('Collected data'), >- helpText: _(''), >+ helpText: '', > widgets: [{ > type: Text, > name: 'firstText', >@@ -161,7 +163,7 @@ > }, { > name: 'transfer', > headerText: _('Transfer the information'), >- helpText: _(''), >+ helpText: '', > widgets: [{ > type: Text, > name: 'firstText', >@@ -181,7 +183,7 @@ > }, { > name: 'uploaded', > headerText: _('Transfered successfully'), >- helpText: _(''), >+ helpText: '', > widgets: [{ > type: Text, > name: 'firstText', >@@ -191,7 +193,7 @@ > }, { > name: 'mail', > headerText: _('Transfer via mail'), >- helpText: _(''), >+ helpText: '', > widgets: [{ > type: Text, > name: 'firstText', >@@ -208,6 +210,16 @@ > layout: [['firstText'], > ['download'], > ['mail']] >+ }, { >+ name: 'uploaded_failed', >+ headerText: _('Error during transfer'), >+ helpText: '', >+ widgets: [{ >+ type: Text, >+ name: 'firstText', >+ content: '<p>' + _('The automatic upload of the archive failed. Please go back and send the archive via e-mail. We apologize for the inconvenience.') + '</p>' >+ }], >+ layout: [['firstText']] > }]; > }, > >@@ -232,7 +244,7 @@ > }, > > hasNext: function(pageName) { >- if (pageName == 'uploaded') { >+ if (pageName == 'uploaded' || pageName == 'mail') { > return false; > } else { > return this.inherited(arguments); >@@ -266,10 +278,17 @@ > if (this.getWidget('transfer', 'method') == 'mail') { > nextPage = 'mail'; > } else { >+ nextPage = new Deferred(); > this.standby(true); > this.uploadArchive().then( > lang.hitch(this, function() { > this.standby(false); >+ nextPage.resolve('upload'); >+ }), >+ lang.hitch(this, function() { >+ this.standby(false); >+ nextPage.resolve('uploaded_failed'); >+ dialog.alert(_('The automatic upload of the archive failed. Please go back and send the archive via e-mail. We apologize for the inconvenience.')); > }) > ); > } >@@ -305,6 +324,9 @@ > return 'transfer'; > } > } >+ if (previousPage == 'mail') { >+ return 'transfer'; >+ } > return previousPage; > }, > >Index: umc/python/sysinfo/__init__.py >=================================================================== >--- umc/python/sysinfo/__init__.py (Revision 40130) >+++ umc/python/sysinfo/__init__.py (Arbeitskopie) >@@ -35,23 +35,24 @@ > import re > import subprocess > >-import univention.info_tools as uit > import univention.management.console as umc > import univention.management.console.modules as umcm > from univention.management.console.log import MODULE >-from univention.management.console.protocol.definitions import * >+from univention.management.console.protocol.definitions import MODULE_ERR, SUCCESS > >-from urllib import quote, urlencode >+from urllib import urlencode > from urlparse import urlunparse > >-# locale module that overrides functions in urllib2 >-import upload >+# local module that overrides functions in urllib2 >+from upload import override_urllib_handlers > import urllib2 > > import univention.config_registry as ucr > > _ = umc.Translation('univention-management-console-module-sysinfo').translate > >+override_urllib_handlers(urllib2) >+ > class Instance(umcm.Base): > def __init__(self): > umcm.Base.__init__(self) >@@ -155,15 +156,18 @@ > fd = open(os.path.join(SYSINFO_PATH, request.options['archive']), 'r') > data = {'filename': fd, } > req = urllib2.Request(url, data, {}) >+ answer = None > try: > u = urllib2.urlopen(req) > answer = u.read() > success = True >- except: >+ except Exception as e: >+ answer = e > success = False > > if not success or answer.startswith('ERROR:'): > request.status = MODULE_ERR >+ MODULE.error('Upload failed: %s' % answer) > else: > request.status = SUCCESS > >Index: umc/python/sysinfo/upload.py >=================================================================== >--- umc/python/sysinfo/upload.py (Revision 40130) >+++ umc/python/sysinfo/upload.py (Arbeitskopie) >@@ -183,11 +183,12 @@ > else: > return self.parent.error('http', req, fp, code, msg, hdrs) > >-urllib2._old_HTTPHandler = urllib2.HTTPHandler >-urllib2.HTTPHandler = newHTTPHandler >- > class newHTTPSHandler(newHTTPHandler): > def https_open(self, req): > return self.do_open(httplib.HTTPS, req) >- >-urllib2.HTTPSHandler = newHTTPSHandler >+ >+def override_urllib_handlers(urllib2_module): >+ urllib2_module._old_HTTPHandler = urllib2_module.HTTPHandler >+ urllib2_module.HTTPHandler = newHTTPHandler >+ urllib2_module.HTTPSHandler = newHTTPSHandler >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 31199
: 5196