accli 2.0.1__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accli
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: IIASA Accelerator Client
5
5
  Author-email: Wrufesh S <wrufesh@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -1,3 +1,3 @@
1
1
  # Please strictly put double quote to use this info for git tag
2
2
  # Read a developer guide for git tag command with regex
3
- VERSION = "v2.0.1"
3
+ VERSION = "v2.0.2"
@@ -39,18 +39,25 @@ def get_db_path():
39
39
 
40
40
  def save_token_details(token, server_url, webcli_url):
41
41
  db_path = get_db_path()
42
-
43
- try:
44
- os.remove(db_path)
45
- except OSError:
46
- pass
47
-
48
42
  db = TinyDB(db_path)
49
- db.insert({
50
- 'token': token,
51
- 'server_url': server_url,
52
- 'webcli_url': webcli_url
53
- })
43
+
44
+ if len(db) > 0:
45
+ doc = next(iter(db))
46
+ doc_id = doc.doc_id
47
+ db.update({
48
+ 'token': token,
49
+ 'server_url': server_url,
50
+ 'webcli_url': webcli_url
51
+ }, doc_ids=[doc_id])
52
+ for extra in list(db):
53
+ if extra.doc_id != doc_id:
54
+ db.remove(doc_ids=[extra.doc_id])
55
+ else:
56
+ db.insert({
57
+ 'token': token,
58
+ 'server_url': server_url,
59
+ 'webcli_url': webcli_url
60
+ })
54
61
 
55
62
 
56
63
  def get_token():
@@ -154,13 +161,21 @@ def get_github_app_token():
154
161
  def set_github_app_token(github_app_token):
155
162
  db_path = get_db_path()
156
163
  db = TinyDB(db_path)
157
- db.update({'github_app_token': github_app_token}, doc_ids=[1])
164
+ if len(db) > 0:
165
+ doc = next(iter(db))
166
+ db.update({'github_app_token': github_app_token}, doc_ids=[doc.doc_id])
167
+ else:
168
+ db.insert({'github_app_token': github_app_token})
158
169
 
159
170
 
160
171
  def set_project_slug(project_slug):
161
172
  db_path = get_db_path()
162
173
  db = TinyDB(db_path)
163
- db.update({'project_slug': project_slug}, doc_ids=[1])
174
+ if len(db) > 0:
175
+ doc = next(iter(db))
176
+ db.update({'project_slug': project_slug}, doc_ids=[doc.doc_id])
177
+ else:
178
+ db.insert({'project_slug': project_slug})
164
179
 
165
180
 
166
181
  def get_project_slug():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accli
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: IIASA Accelerator Client
5
5
  Author-email: Wrufesh S <wrufesh@gmail.com>
6
6
  License: The MIT License (MIT)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes