Commit 63996d3a authored by abuddenberg's avatar abuddenberg
Browse files

Refactored config file handling to module-level. hitlist files now created in...

Refactored config file handling to module-level. hitlist files now created in current directory (better than crash; will fix later)
parent cb0eb50d
...@@ -14,13 +14,14 @@ gcis = GcisClient('http://data-stage.globalchange.gov', 'andrew.buddenberg@noaa. ...@@ -14,13 +14,14 @@ gcis = GcisClient('http://data-stage.globalchange.gov', 'andrew.buddenberg@noaa.
def main(): def main():
hitlist_file = '../hitlist.pk1' hitlist_file = 'hitlist.pk1'
# create_problem_list('nca3', hitlist_file) # create_problem_list('nca3', hitlist_file)
# print_problem_list(hitlist_file) # print_problem_list(hitlist_file)
solve_problems(hitlist_file, 'nca3') solve_problems(hitlist_file, 'nca3')
# print_ready_list(hitlist_file) # print_ready_list(hitlist_file)
def solve_problems(path, report_id): def solve_problems(path, report_id):
problems = load_problem_list(path) problems = load_problem_list(path)
......
from gcis_client import GcisClient from gcis_client import GcisClient
from webform_client import WebformClient from webform_client import WebformClient
from os.path import expanduser, exists
from os import makedirs
def default_image_dir():
image_dir = expanduser('~/.gcis-py-client/images/')
if not exists(image_dir):
makedirs(image_dir)
return image_dir
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
import urllib import urllib
import re import re
from os.path import join, expanduser, exists from os.path import join
from os import makedirs
import requests import requests
from dateutil.parser import parse from dateutil.parser import parse
...@@ -22,18 +21,18 @@ def sanitized(pattern): ...@@ -22,18 +21,18 @@ def sanitized(pattern):
return dec return dec
def build_image_dir():
image_dir = expanduser('~/.gcis-py-client/images/')
if not exists(image_dir):
makedirs(image_dir)
return image_dir
class WebformClient: class WebformClient:
def __init__(self, url, token, local_image_dir=None, remote_dir='/system/files/'): def __init__(self, url, token, local_image_dir=None, remote_dir='/system/files/'):
self.base_url = url self.base_url = url
self.token = token self.token = token
self.images_dir = local_image_dir if local_image_dir else build_image_dir()
if local_image_dir:
self.images_dir = local_image_dir
else:
from gcis_clients import default_image_dir
self.images_dir = default_image_dir()
self.remote_image_dir = remote_dir self.remote_image_dir = remote_dir
def get_list(self): def get_list(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment