Bug 1547763

Summary: redhat-support-tool: UnboundLocalError: local variable 'timer' referenced before assignment
Product: Red Hat Enterprise Linux 7 Reporter: Ryan Blakley <rblakley>
Component: redhat-support-toolAssignee: A.P. Rajshekhar <randalap>
Status: CLOSED ERRATA QA Contact: Miroslav HradĂ­lek <mhradile>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: bishop, bubrown, cww, mhradile, pghole, snavale, vrathee
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1882771 (view as bug list) Environment:
Last Closed: 2020-03-31 20:05:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1722515, 1882771    

Description Ryan Blakley 2018-02-21 21:23:38 UTC
Description of problem:redhat-support-tool: UnboundLocalError: local variable 'timer' referenced before assignment.


Version-Release number of selected component (if applicable): redhat-support-tool-0.9.9-3.el7


Steps to Reproduce:
1. For me to reproduce the issue, I had to bring down my networking.
2. Then run # redhat-support-tool addattachment -c 0XXXXXX -f -z /path/to/file


Actual results:
redhat_support_tool.helpers.launchhelper - ERROR - local variable 'timer' referenced before assignment
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/redhat_support_tool/helpers/launchhelper.py", line 106, in run
    return cls.non_interactive_action()
  File "/usr/lib/python2.7/site-packages/redhat_support_tool/plugins/add_attachment.py", line 437, in non_interactive_action
    useFtp=self.use_ftp)
  File "/usr/lib/python2.7/site-packages/redhat_support_lib/infrastructure/brokers.py", line 612, in add
    amnt = FtpHelper.ftp_attachment(fileName, caseNumber, fileChunk)
  File "/usr/lib/python2.7/site-packages/redhat_support_lib/utils/ftphelper.py", line 135, in ftp_attachment
    timer.stop()
UnboundLocalError: local variable 'timer' referenced before assignment


Expected results: Upload the file to the dropbox.


Additional info: I threw together the below patch, and the customer confirmed after making the changes in the patch, that the issue was resolved and the file uploaded.


# diff -up /usr/lib/python2.7/site-packages/redhat_support_lib/utils/ftphelper.py.old /usr/lib/python2.7/site-packages/redhat_support_lib/utils/ftphelper.py
--- /usr/lib/python2.7/site-packages/redhat_support_lib/utils/ftphelper.py.old	2018-02-19 10:54:15.342719682 -0500
+++ /usr/lib/python2.7/site-packages/redhat_support_lib/utils/ftphelper.py	2018-02-19 10:54:22.409917659 -0500
@@ -56,6 +56,7 @@ def ftp_attachment(fileName=None, caseNu
     conn = None
     ftp = None
     fh = None
+    timer = None
     # add http to host because if it is not prefixed it defaults to https
     try:
         if config.proxy_url != None:
@@ -132,7 +133,7 @@ def ftp_attachment(fileName=None, caseNu
             if _ftp_error_return_code(resp):
                 raise Exception(resp)
     finally:
-	timer.stop()
+        if timer: timer.stop()
         if fh: fh.close()
         if config.proxy_url != None:
             if conn: conn.close()

Comment 2 Bishop Clark 2018-07-26 16:27:52 UTC
Can confirm:  the above patch changes the behaviour and allows the tool to run.  THANKS, RYAN!!

Comment 10 errata-xmlrpc 2020-03-31 20:05:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:1134