Skip to content

Commit b9cd68e

Browse files
committed
make server parameters editable in ini file
1 parent 3c44fcb commit b9cd68e

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

dvcurator/gui.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def load_config(self, path=None):
8282
import configparser
8383
config = configparser.ConfigParser()
8484
config.read(path)
85+
self.dataverse_host.set(config['default']['dataverse_host'])
86+
self.curation_repo.set(config['default']['curation_repo'])
87+
self.github_org.set(config['default']['github_org'])
8588
self.dv_token.set(config['default']['dataverse_token'])
8689
self.gh_token.set(config['default']['github_token'])
8790
self.dropbox.set(config['default']['dropbox'])
@@ -101,12 +104,23 @@ def save_config_as(self):
101104

102105
def save_config(self, path=None):
103106
"""
104-
Save variables to a
107+
Save variables to a ini file
105108
"""
106109
path = self.local_ini if not path else path
110+
import dvcurator.hosts
111+
if (self.dataverse_host.get() == ""):
112+
self.dataverse_host.set(dvcurator.hosts.qdr_dataverse"")
113+
if (self.curation_repo.get() == ""):
114+
self.curation_repo.set(dvcurator.hosts.curation_repo)
115+
if (self.github_org.get() == ""):
116+
self.github_org.set(dvcurator.host)
117+
107118
import configparser
108119
config = configparser.ConfigParser()
109-
config['default'] = {"dataverse_token": self.dv_token.get(),
120+
config['default'] = {"dataverse_host": self.dataverse_host.get(),
121+
"curation_repo": self.curation_repo.get(),
122+
"github_org": self.github_org.get(),
123+
"dataverse_token": self.dv_token.get(),
110124
"github_token": self.gh_token.get(),
111125
"dropbox": self.dropbox.get()}
112126
with open(path, 'w') as config_file:
@@ -186,7 +200,7 @@ def load_citation(self):
186200
print("Error: Set valid Dropbox folder first")
187201
return
188202
# Grab the citation
189-
self.metadata = dvcurator.dataverse.get_metadata(self.doi.get(), self.dv_token.get())
203+
self.metadata = dvcurator.dataverse.get_metadata(self.doi.get(), self.dv_token.get(), self.dataverse_host.get())
190204
if (not self.metadata):
191205
print("Error: citation failed to load.")
192206
return
@@ -224,7 +238,7 @@ def make_github(self):
224238
self.disable_buttons()
225239

226240
t = threading.Thread(target=dvcurator.github.create_project,
227-
args=(self.project_name, self.gh_token.get()))
241+
args=(self.project_name, self.gh_token.get(), self.curation_repo.get()))
228242

229243
t.start()
230244
self.schedule_check(t)
@@ -338,9 +352,14 @@ def __init__(self, parent, *args, **kwargs):
338352
self.editmenu.add_command(label="Select project subfolder manually", command=self.set_subfolder)
339353
self.menubar.add_cascade(label="File processing", menu=self.editmenu)
340354
self.menubar.entryconfig("File processing", state=tk.DISABLED)
355+
341356
parent.config(menu=self.menubar)
342357

343358
# Settings
359+
self.github_org = tk.StringVar()
360+
self.curator_repo = tk.StringVar()
361+
self.dataverse_host = tk.StringVar()
362+
344363
settings = tk.Frame(self)
345364

346365
self.doi=tk.StringVar()

dvcurator/hosts.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
# Variable terms
12
qdr_dataverse = "https://data.qdr.syr.edu"
2-
qdr_doi_path = qdr_dataverse + "/dataset.xhtml?persistentId="
3-
github_api='https://api.github.com'
43
github_org = "QualitativeDataRepository"
54
curation_repo = "QualitativeDataRepository/Project-Curation"
5+
6+
# Constants
7+
qdr_doi_path = qdr_dataverse + "/dataset.xhtml?persistentId="
8+
github_api='https://api.github.com'
69
pkg_repo = "QualitativeDataRepository/dvcurator-python"
10+

0 commit comments

Comments
 (0)