def other_other_work(): my_dict = [] for i in range(0, 84000, 1000): try: jira_data_file_with_path = str( project_dir_path ) + "/data/cache_data/cas_project_all_jira_" + str(i) + ".json" result = CachedIssues.load(open(jira_data_file_with_path)) my_dict.extend(result) except Exception as e: print(e) jira_data_file_with_path = str( project_dir_path ) + "/data/cache_data/cas_project_all_jira_detailed.json" log.info("Saving JIRA Data to -> " + jira_data_file_with_path) cached = CachedIssues(my_dict) cached.dump(open(jira_data_file_with_path, 'w')) log.info("Data Saved!")
def load_data_for_filter(authed_jira, jira_filter, filter_name, refresh_filter_result=False, load_full_data=False, cache_data=False): try: if refresh_filter_result: result = load_and_save_full_data_for_filter( authed_jira, jira_filter, filter_name, load_full_data, cache_data) else: jira_data_file_with_path = str( project_dir_path) + "/data/cache_data/" + filter_name + ".json" result = CachedIssues.load(open(jira_data_file_with_path)) return result except Exception as e: log.exception(e) return None
sys.path.append(os.path.dirname(__file__)) import commit_features as cf import time output_dir_eszz = "../Enhanced_SZZ/outputs/hive/" output_dir_szz = "../SZZ/outputs/hive/" repo_dir = "../Enhanced_SZZ/repos/hive/" repo_name = "hive" print("Initializing repo...") repo = Repo.init(repo_dir) print("Initializing JIRA...") options = {'server': 'https://issues.apache.org/jira'} jira = JIRA(options=options) print("Load cached jira issues...") saved_jira_path = "../Enhanced_SZZ/jira/hive/issue_cache.json" ISSUES = CachedIssues.load(open(saved_jira_path)) def get_jira_id(commit): result = re.search( '(' + repo_name.upper() + '[-,_]{1}[0-9]+|HADOOP[-,_]{1}[0-9]+)', commit.message, re.IGNORECASE) if result is not None: return result.group(0).replace("_", "-", 1) else: return None def get_jira_issue(commit): jira_id = get_jira_id(commit=commit) if jira_id is not None:
except JIRAError as e: if e.status_code == 429: print("Got 429 (rate-limited) response from server.") print(e.text) exit_msg = "Exiting " + time.asctime( time.localtime(time.time())) sys.exit(exit_msg) else: print(e.text) except Exception as e: print("Some other exception occured.") print(e) else: print("Load issues from cache.") ISSUES = CachedIssues.load(open(jira_issue_path)) # load refactorings print("Load refactorings") REFACTORINGS = pd.read_csv("refactorings.csv") ########################### # COMMITS ########################### commits = repo.iter_commits() ########################### # COMMIT FILTERS ########################### commit_filters = [commit_filter_has_jira, commit_filter_jira_type_is_bug] for f in commit_filters:
import sys sys.path.insert(0, '..') from jira import JIRA from jira_cache import CachedIssues print('Connecting to https://jira.atlassian.com...') jira = JIRA('https://jira.atlassian.com/') result = jira.search_issues('project=JRA and text ~ "Python"', expand='changelog') print('Caching %i issues...' % len(result)) cached = CachedIssues(result) cached.dump(open('python-issues.json', 'w')) print('Loading issues from dump...') print(CachedIssues.load(open('python-issues.json')))