Make url an option

This commit is contained in:
Andy Teijelo Pérez 2017-04-13 15:12:48 -04:00
parent 20467e9e07
commit 0f7d1fa6d2

View file

@ -4,20 +4,24 @@ import sys
import time
import json
import requests
import argparse
import subprocess
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
#from requests.packages.urllib3.exceptions import InsecureRequestWarning
#requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
date = time.localtime()
if len(sys.argv) > 1:
date = subprocess.check_output(['date','-d',sys.argv[1],'+%s'])
date = float(date)
date = time.localtime(date)
parser = argparse.ArgumentParser()
parser.add_argument('-b', '--base-url', required=True)
parser.add_argument('-d', '--date', default="today")
args = parser.parse_args()
date = subprocess.check_output(['date','-d',args.date,'+%s'])
date = float(date)
date = time.localtime(date)
date = time.strftime(r'%Y-%m-%d', date)
url_template = 'https://jira.bloopark.com/rest/tempo-timesheets/3/worklogs?projectKey=PAS&dateFrom={}&dateTo={}&expand=issue.status'
url_template = 'https://{base_url}/rest/tempo-timesheets/3/worklogs?projectKey=PAS&dateFrom={date}&dateTo={date}&expand=issue.status'
url = url_template.format(base_url=args.base_url, date=date)
resp = requests.get(url_template.format(date, date), verify=False)
resp = requests.get(url, verify=False)
print(json.dumps(resp.json()))