Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6599631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:30:58+00:00 2026-05-25T18:30:58+00:00

Here is the code: 1 #!/usr/bin/env python 2 3 import re, os, sys, jira,

  • 0

Here is the code:

 1 #!/usr/bin/env python
  2 
  3 import re, os, sys, jira, subprocess
  4 
  5 class Check_jira:
  6 
  7     def verify_commit_text(self, tags):
  8         for line in tags:
  9             if re.match('^NO-TIK',line):
 10                 return True
 11             elif re.match('^NO-REVIEW', line):
 12                 return True
 13             elif re.match(r'[a-zA-Z]+-\d+', line):
 14                 # Validate the JIRA ID
 15                 m = re.search("([a-zA-Z]+-\d+)",line)
 16                 if m:
 17                     my_args = m.group(1)
 18                     result = Check_jira.CheckForJiraIssueRecord(my_args)
 19                     if result == False:
 20                         util.warn("%s does not exist"%my_args)
 21                     else:
 22                         return True
 23                 return True
 24             else:
 25                 return False
 26 if __name__ == '__main__':
 27     p = Check_jira()
 28     commit_text_verified = p.verify_commit_text(os.popen('hg tip --template "{desc}"'))
 29 
 30     if (commit_text_verified):
 31         sys.exit(0)
 32     else:
 33         print >> sys.stderr, ('[obey the rules!]')
 34         sys.exit(1);
 35     def CheckForJiraIssueRecord(object):
 36    
 37         sys.stdout = os.devnull
 38         sys.stderr = os.devnull
 39 
 40    
 41         try:
 42             com = jira.Commands()
 43             logger = jira.setupLogging()
 44             jira_env = {'home':os.environ['HOME']}
 45             command_cat= "cat"
 46             command_logout= "logout"
 47             #my_args = ["QA-656"]
 48             server = "http://jira.myserver.com:8080/rpc/soap/jirasoapservice-v2?wsdl"
 49         except Exception, e:
 50             sys.exit('config error')
 51 
 52 class Options:
 53     pass
 54 options = Options()
 55 
 56 options.user = 'user'
 57 options.password = 'password'
 58 
 59 try:
 60 
 61     jira.soap = jira.Client(server)
 62     jira.start_login(options, jira_env, command_cat, com, logger)
 63     issue = com.run(command_cat, logger, jira_env, my_args)
 64 except Exception, e:
 65     print sys.exit('data error')

so maybe:
1. if name == ‘main‘: shoudl be at the bottom ?
2. So, i have 2 classes (Check_jira) and (Options)
3. Check_jira has 2 functions verify_commit_text() and CheckForJiraIssueRecord()
4. I pass object as an argument to CheckForJiraIssueRecord since i am passing my_args to it , on its usage.
5. Not sure how to call one function from another function in the same class
6. Error i am getting is :

Traceback (most recent call last):
  File "/home/qa/hook-test/.hg/check_jira.py", line 31, in 
    commit_text_verified = p.verify_commit_text(os.popen('hg tip --template "{desc}"'))
  File "/home/qa/hook-test/.hg/check_jira.py", line 21, in verify_commit_text
    result = Check_jira.CheckForJiraIssueRecord(my_args)
AttributeError: class Check_jira has no attribute 'CheckForJiraIssueRecord'
transaction abort!
rollback completed
abort: pretxncommit.jira hook exited with status 1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:30:59+00:00Added an answer on May 25, 2026 at 6:30 pm

    class Check_jira ends on line 25 and has only one method. Then you have an if block, and CheckForJiraIssueRecord is just a function defined in this block (that is, the function is defined if __name__ == '__main__'.

    Just put the if block outside after the whole class definition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the code here below: #!/usr/bin/env python import wx class MyForm(wx.Frame): def __init__(self): wx.Frame.__init__(self, None,
I have the following code: #!/usr/bin/env python import sys from PyQt4 import QtGui, QtCore
In Groovy code something simple: #!/usr/bin/env groovy public class test { boolean val def
The code #!/usr/bin/env python import MySQLdb print Content-Type: text/html print print <html><head><title>Books</title></head> print <body>
Here is my code: #!/usr/bin/env perl sub start { ... } sub stop {
Im using python markdown for my django project, when i have the value #/usr/bin/env
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code from MSDN . I don't understand why the work isn't just
enter code here I have a table on SQL server 2005 with bigint primary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.