gibson-cli 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

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.
Files changed (113) hide show
  1. gibson/api/BaseApi.py +112 -0
  2. {api → gibson/api}/Cli.py +21 -59
  3. {bin → gibson/bin}/gibson.py +2 -2
  4. {command → gibson/command}/Api.py +5 -6
  5. {command → gibson/command}/Base.py +4 -5
  6. {command → gibson/command}/BaseCommand.py +2 -2
  7. {command → gibson/command}/Build.py +2 -3
  8. {command → gibson/command}/Code.py +12 -11
  9. {command → gibson/command}/Conf.py +1 -1
  10. {command → gibson/command}/Dev.py +2 -3
  11. {command → gibson/command}/Import.py +4 -5
  12. {command → gibson/command}/List.py +2 -3
  13. {command → gibson/command}/Merge.py +2 -3
  14. {command → gibson/command}/Model.py +4 -5
  15. {command → gibson/command}/Models.py +4 -5
  16. {command → gibson/command}/Modify.py +2 -3
  17. {command → gibson/command}/Module.py +2 -3
  18. {command → gibson/command}/New.py +2 -3
  19. {command → gibson/command}/OpenApi.py +2 -3
  20. {command → gibson/command}/Question.py +2 -3
  21. {command → gibson/command}/Remove.py +3 -4
  22. {command → gibson/command}/Rename.py +3 -4
  23. {command → gibson/command}/Rewrite.py +3 -3
  24. {command → gibson/command}/Schema.py +4 -5
  25. {command → gibson/command}/Schemas.py +4 -5
  26. {command → gibson/command}/Test.py +4 -5
  27. {command → gibson/command}/Tests.py +4 -5
  28. {command → gibson/command}/Version.py +2 -2
  29. {command → gibson/command}/WarGames.py +2 -3
  30. {command → gibson/command}/auth/Auth.py +3 -3
  31. gibson/command/auth/Login.py +20 -0
  32. {command → gibson/command}/auth/Logout.py +1 -1
  33. {command → gibson/command}/tests/test_command_BaseCommand.py +2 -2
  34. {command → gibson/command}/tests/test_command_Conf.py +2 -2
  35. {conf → gibson/conf}/Dev.py +4 -4
  36. {conf → gibson/conf}/tests/test_conf_Dependencies.py +1 -1
  37. {conf → gibson/conf}/tests/test_conf_Platform.py +1 -1
  38. {core → gibson/core}/CommandRouter.py +34 -34
  39. gibson/core/Completions.py +35 -0
  40. {core → gibson/core}/Configuration.py +24 -11
  41. {core → gibson/core}/Conversation.py +8 -5
  42. {core → gibson/core}/Env.py +2 -2
  43. {core → gibson/core}/Memory.py +1 -1
  44. gibson/data/bash-completion.tmpl +96 -0
  45. {db → gibson/db}/tests/test_db_TableExceptions.py +1 -1
  46. {dev → gibson/dev}/Dev.py +2 -11
  47. {display → gibson/display}/tests/test_display_Header.py +1 -1
  48. {display → gibson/display}/tests/test_display_WorkspaceFooter.py +1 -1
  49. {display → gibson/display}/tests/test_display_WorkspaceHeader.py +1 -1
  50. {lang → gibson/lang}/Python.py +1 -1
  51. {lang → gibson/lang}/tests/test_lang_Python.py +1 -1
  52. {services → gibson/services}/auth/Server.py +11 -6
  53. {services → gibson/services}/code/context/schema/EntityKeys.py +3 -3
  54. {services → gibson/services}/code/context/schema/Manager.py +2 -2
  55. {services → gibson/services}/code/context/schema/tests/test_code_context_schema_DataDictionary.py +1 -1
  56. {services → gibson/services}/code/context/schema/tests/test_code_context_schema_EntityKeys.py +4 -4
  57. {services → gibson/services}/code/context/schema/tests/test_code_context_schema_Manager.py +2 -2
  58. {services → gibson/services}/code/customization/Authenticator.py +2 -2
  59. {services → gibson/services}/code/customization/BaseCustomization.py +1 -1
  60. {services → gibson/services}/code/customization/CustomizationManager.py +2 -2
  61. {services → gibson/services}/code/customization/tests/test_code_customization_Authenticator.py +2 -2
  62. {services → gibson/services}/code/customization/tests/test_code_customization_BaseCustomization.py +2 -2
  63. {structure → gibson/structure}/Entity.py +2 -2
  64. {structure → gibson/structure}/keys/ForeignKey.py +1 -1
  65. {structure → gibson/structure}/keys/Index.py +1 -1
  66. {structure → gibson/structure}/keys/tests/test_ForeignKey.py +2 -2
  67. {structure → gibson/structure}/keys/tests/test_Index.py +1 -1
  68. {structure → gibson/structure}/keys/tests/test_IndexAttribute.py +1 -1
  69. {structure → gibson/structure}/testing.py +1 -1
  70. {structure → gibson/structure}/tests/test_Entity.py +5 -5
  71. gibson/tests/test_Env.py +14 -0
  72. gibson/tests/test_Memory.py +89 -0
  73. gibson/tests/test_utils.py +20 -0
  74. {gibson_cli-0.1.2.dist-info → gibson_cli-0.1.4.dist-info}/METADATA +1 -1
  75. gibson_cli-0.1.4.dist-info/RECORD +108 -0
  76. {gibson_cli-0.1.2.dist-info → gibson_cli-0.1.4.dist-info}/WHEEL +1 -1
  77. gibson_cli-0.1.4.dist-info/entry_points.txt +2 -0
  78. gibson_cli-0.1.4.dist-info/top_level.txt +1 -0
  79. api/BaseApi.py +0 -45
  80. command/auth/Login.py +0 -20
  81. gibson_cli-0.1.2.dist-info/RECORD +0 -103
  82. gibson_cli-0.1.2.dist-info/entry_points.txt +0 -2
  83. gibson_cli-0.1.2.dist-info/top_level.txt +0 -12
  84. {command → gibson/command}/Count.py +0 -0
  85. {command → gibson/command}/Forget.py +0 -0
  86. {command → gibson/command}/Show.py +0 -0
  87. {command → gibson/command}/Tree.py +0 -0
  88. {conf → gibson/conf}/Api.py +0 -0
  89. {conf → gibson/conf}/Code.py +0 -0
  90. {conf → gibson/conf}/Custom.py +0 -0
  91. {conf → gibson/conf}/Datastore.py +0 -0
  92. {conf → gibson/conf}/Dependencies.py +0 -0
  93. {conf → gibson/conf}/Frameworks.py +0 -0
  94. {conf → gibson/conf}/Modeler.py +0 -0
  95. {conf → gibson/conf}/Paths.py +0 -0
  96. {conf → gibson/conf}/Platform.py +0 -0
  97. {conf → gibson/conf}/Project.py +0 -0
  98. {conf → gibson/conf}/Version.py +0 -0
  99. {conf → gibson/conf}/dev/Api.py +0 -0
  100. {conf → gibson/conf}/dev/Base.py +0 -0
  101. {conf → gibson/conf}/dev/Model.py +0 -0
  102. {conf → gibson/conf}/dev/Schema.py +0 -0
  103. {core → gibson/core}/TimeKeeper.py +0 -0
  104. {core → gibson/core}/utils.py +0 -0
  105. {data → gibson/data}/default-ref-table.tmpl +0 -0
  106. {data → gibson/data}/default-table.tmpl +0 -0
  107. {db → gibson/db}/TableExceptions.py +0 -0
  108. {display → gibson/display}/Header.py +0 -0
  109. {display → gibson/display}/WorkspaceFooter.py +0 -0
  110. {display → gibson/display}/WorkspaceHeader.py +0 -0
  111. {services → gibson/services}/code/context/schema/DataDictionary.py +0 -0
  112. {structure → gibson/structure}/constraints/ReferenceConstraint.py +0 -0
  113. {structure → gibson/structure}/keys/IndexAttribute.py +0 -0
@@ -1,9 +1,8 @@
1
1
  import hashlib
2
2
  import sys
3
3
 
4
- from core.Conversation import Conversation
5
-
6
- from .BaseCommand import BaseCommand
4
+ from gibson.command.BaseCommand import BaseCommand
5
+ from gibson.core.Conversation import Conversation
7
6
 
8
7
 
9
8
  class WarGames(BaseCommand):
@@ -1,8 +1,8 @@
1
1
  import sys
2
2
 
3
- from ..BaseCommand import BaseCommand
4
- from .Login import Login
5
- from .Logout import Logout
3
+ from gibson.command.auth.Login import Login
4
+ from gibson.command.auth.Logout import Logout
5
+ from gibson.command.BaseCommand import BaseCommand
6
6
 
7
7
 
8
8
  class Auth(BaseCommand):
@@ -0,0 +1,20 @@
1
+ from gibson.api.BaseApi import BaseApi
2
+ from gibson.command.BaseCommand import BaseCommand
3
+ from gibson.services.auth.Server import Server as AuthServer
4
+
5
+
6
+ class Login(BaseCommand):
7
+ def execute(self):
8
+ api = BaseApi(self.configuration)
9
+ access_token, refresh_token = AuthServer(api.app_domain()).get_tokens()
10
+
11
+ if access_token is None or refresh_token is None:
12
+ self.conversation.newline()
13
+ self.conversation.type(
14
+ "Login failed, please try again with `gibson auth login`."
15
+ )
16
+ else:
17
+ self.configuration.set_auth_tokens(access_token, refresh_token)
18
+ self.conversation.type(f"Welcome! You are now logged in.")
19
+
20
+ self.conversation.newline()
@@ -1,4 +1,4 @@
1
- from ..BaseCommand import BaseCommand
1
+ from gibson.command.BaseCommand import BaseCommand
2
2
 
3
3
 
4
4
  class Logout(BaseCommand):
@@ -1,5 +1,5 @@
1
- from command.BaseCommand import BaseCommand
2
- from core.Configuration import Configuration
1
+ from gibson.command.BaseCommand import BaseCommand
2
+ from gibson.core.Configuration import Configuration
3
3
 
4
4
 
5
5
  def test_customization_management():
@@ -1,5 +1,5 @@
1
- from command.Conf import Conf
2
- from core.Configuration import Configuration
1
+ from gibson.command.Conf import Conf
2
+ from gibson.core.Configuration import Configuration
3
3
 
4
4
 
5
5
  def test_get_configuration_keys():
@@ -1,9 +1,9 @@
1
1
  import os
2
2
 
3
- from conf.dev.Api import Api
4
- from conf.dev.Base import Base
5
- from conf.dev.Model import Model
6
- from conf.dev.Schema import Schema
3
+ from gibson.conf.dev.Api import Api
4
+ from gibson.conf.dev.Base import Base
5
+ from gibson.conf.dev.Model import Model
6
+ from gibson.conf.dev.Schema import Schema
7
7
 
8
8
 
9
9
  class Dev:
@@ -1,4 +1,4 @@
1
- from conf.Dependencies import Dependencies
1
+ from gibson.conf.Dependencies import Dependencies
2
2
 
3
3
 
4
4
  def test_compute():
@@ -1,6 +1,6 @@
1
1
  import platform
2
2
 
3
- from conf.Platform import Platform
3
+ from gibson.conf.Platform import Platform
4
4
 
5
5
 
6
6
  def test_system():
@@ -1,39 +1,39 @@
1
1
  import sys
2
2
 
3
- from command.Api import Api
4
- from command.auth.Auth import Auth
5
- from command.Base import Base
6
- from command.Build import Build
7
- from command.Code import Code
8
- from command.Conf import Conf
9
- from command.Count import Count
10
- from command.Dev import Dev
11
- from command.Forget import Forget
12
- from command.Import import Import
13
- from command.List import List
14
- from command.Merge import Merge
15
- from command.Model import Model
16
- from command.Models import Models
17
- from command.Modify import Modify
18
- from command.Module import Module
19
- from command.New import New
20
- from command.OpenApi import OpenApi
21
- from command.Question import Question
22
- from command.Remove import Remove
23
- from command.Rename import Rename
24
- from command.Rewrite import Rewrite
25
- from command.Schema import Schema
26
- from command.Schemas import Schemas
27
- from command.Show import Show
28
- from command.Test import Test
29
- from command.Tests import Tests
30
- from command.Tree import Tree
31
- from command.Version import Version
32
- from command.WarGames import WarGames
33
- from .Configuration import Configuration
34
- from .Conversation import Conversation
35
- from .Env import Env
36
- from .Memory import Memory
3
+ from gibson.command.Api import Api
4
+ from gibson.command.auth.Auth import Auth
5
+ from gibson.command.Base import Base
6
+ from gibson.command.Build import Build
7
+ from gibson.command.Code import Code
8
+ from gibson.command.Conf import Conf
9
+ from gibson.command.Count import Count
10
+ from gibson.command.Dev import Dev
11
+ from gibson.command.Forget import Forget
12
+ from gibson.command.Import import Import
13
+ from gibson.command.List import List
14
+ from gibson.command.Merge import Merge
15
+ from gibson.command.Model import Model
16
+ from gibson.command.Models import Models
17
+ from gibson.command.Modify import Modify
18
+ from gibson.command.Module import Module
19
+ from gibson.command.New import New
20
+ from gibson.command.OpenApi import OpenApi
21
+ from gibson.command.Question import Question
22
+ from gibson.command.Remove import Remove
23
+ from gibson.command.Rename import Rename
24
+ from gibson.command.Rewrite import Rewrite
25
+ from gibson.command.Schema import Schema
26
+ from gibson.command.Schemas import Schemas
27
+ from gibson.command.Show import Show
28
+ from gibson.command.Test import Test
29
+ from gibson.command.Tests import Tests
30
+ from gibson.command.Tree import Tree
31
+ from gibson.command.Version import Version
32
+ from gibson.command.WarGames import WarGames
33
+ from gibson.core.Configuration import Configuration
34
+ from gibson.core.Conversation import Conversation
35
+ from gibson.core.Env import Env
36
+ from gibson.core.Memory import Memory
37
37
 
38
38
 
39
39
  class CommandRouter:
@@ -0,0 +1,35 @@
1
+ import os
2
+
3
+
4
+ class Completions:
5
+ def __init__(self):
6
+ self.user_home = os.environ.get("HOME")
7
+ self.gibson_config = ".gibsonai"
8
+
9
+ def install(self):
10
+ completions_location = f"$HOME/{self.gibson_config}/bash_completion"
11
+ installation = f"""\n[ -s "{completions_location}" ] && \\. "{completions_location}" # Load gibson auto completion\n"""
12
+
13
+ with open(f"{self.user_home}/.bashrc", "r+") as f:
14
+ if completions_location not in f.read():
15
+ f.write(installation)
16
+
17
+ with open(f"{self.user_home}/.zshrc", "r+") as f:
18
+ if completions_location not in f.read():
19
+ f.write(installation)
20
+
21
+ return self
22
+
23
+ def write(self):
24
+ try:
25
+ file = os.path.dirname(__file__) + f"/../data/bash-completion.tmpl"
26
+ with open(file, "r") as f:
27
+ contents = f.read()
28
+ except FileNotFoundError:
29
+ return self
30
+
31
+ completions = f"{self.user_home}/{self.gibson_config}/bash_completion"
32
+ with open(completions, "w") as f:
33
+ f.write(contents)
34
+
35
+ return self
@@ -5,15 +5,12 @@ import shutil
5
5
  import sys
6
6
  import time
7
7
 
8
- from conf.Dependencies import Dependencies
9
- from conf.dev.Api import Api
10
- from conf.dev.Base import Base
11
- from conf.dev.Model import Model
12
- from conf.dev.Schema import Schema
13
- from conf.Platform import Platform
14
- from conf.Project import Project
15
- from conf.Paths import ConfigPaths
16
- from .Conversation import Conversation
8
+ from gibson.conf.Dependencies import Dependencies
9
+ from gibson.conf.Platform import Platform
10
+ from gibson.conf.Project import Project
11
+ from gibson.conf.Paths import ConfigPaths
12
+ from gibson.core.Completions import Completions
13
+ from gibson.core.Conversation import Conversation
17
14
 
18
15
 
19
16
  class Configuration:
@@ -38,6 +35,8 @@ class Configuration:
38
35
 
39
36
  self.read_config()
40
37
 
38
+ Completions().write().install()
39
+
41
40
  def append_project_to_conf(self, project_name, project_description):
42
41
  self.project.api.key = "FIXME"
43
42
  self.project.name = project_name
@@ -270,6 +269,16 @@ class Configuration:
270
269
 
271
270
  def get_my_settings(self):
272
271
  return self.settings[self.project.name]
272
+
273
+ def get_refresh_token(self):
274
+ try:
275
+ with open(f"{self.paths.auth}/{self.API_ENV}", "r") as f:
276
+ contents = f.read()
277
+ except FileNotFoundError:
278
+ return None
279
+
280
+ token = json.loads(contents)
281
+ return token["refresh_token"]
273
282
 
274
283
  def initialize(self):
275
284
  self.conversation.message_welcome()
@@ -351,14 +360,18 @@ class Configuration:
351
360
 
352
361
  return self
353
362
 
354
- def set_access_token(self, token):
363
+ def set_auth_tokens(self, access_token, refresh_token):
355
364
  try:
356
365
  os.mkdir(self.paths.auth)
357
366
  except FileExistsError:
358
367
  pass
359
368
 
360
369
  with open(f"{self.paths.auth}/{self.API_ENV}", "w") as f:
361
- f.write(json.dumps({"access_token": token}))
370
+ f.write(
371
+ json.dumps(
372
+ {"access_token": access_token, "refresh_token": refresh_token}
373
+ )
374
+ )
362
375
 
363
376
  def set_config_paths(self, ignore_env_vars=False):
364
377
  user_home = os.environ.get("HOME")
@@ -5,7 +5,7 @@ import time
5
5
 
6
6
  import pyfiglet
7
7
 
8
- from conf.Version import Version
8
+ from gibson.conf.Version import Version
9
9
 
10
10
 
11
11
  class Conversation:
@@ -234,10 +234,13 @@ class Conversation:
234
234
  if self.__delay is not None:
235
235
  delay = self.__delay
236
236
 
237
- for char in message:
238
- sys.stdout.write(char)
239
- sys.stdout.flush()
240
- time.sleep(delay)
237
+ try:
238
+ for char in message:
239
+ sys.stdout.write(char)
240
+ sys.stdout.flush()
241
+ time.sleep(delay)
242
+ except KeyboardInterrupt:
243
+ exit(1)
241
244
 
242
245
  def unmute(self):
243
246
  self.__mute = False
@@ -1,5 +1,5 @@
1
- from .Configuration import Configuration
2
- from lang.Python import Python
1
+ from gibson.core.Configuration import Configuration
2
+ from gibson.lang.Python import Python
3
3
 
4
4
 
5
5
  class Env:
@@ -1,7 +1,7 @@
1
1
  import json
2
2
  import os
3
3
 
4
- from .Configuration import Configuration
4
+ from gibson.core.Configuration import Configuration
5
5
 
6
6
 
7
7
  class Memory:
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # bash completion for Gibson CLI
4
+
5
+ if ! command -v gibson &>/dev/null; then
6
+ return
7
+ fi
8
+
9
+ __gibson_generate_completion() {
10
+ declare current_word
11
+ current_word="${COMP_WORDS[COMP_CWORD]}"
12
+ # shellcheck disable=SC2207
13
+ COMPREPLY=($(compgen -W "$1" -- "${current_word}"))
14
+ return 0
15
+ }
16
+
17
+ __gibson_commands_and_options() {
18
+ declare current_word
19
+ declare command
20
+
21
+ current_word="${COMP_WORDS[COMP_CWORD]}"
22
+ COMMANDS='
23
+ auth
24
+ build
25
+ code
26
+ conf
27
+ count
28
+ create
29
+ dev
30
+ forget
31
+ help
32
+ import
33
+ list
34
+ merge
35
+ model
36
+ modify
37
+ new
38
+ openapi
39
+ project
40
+ question
41
+ remove
42
+ rename
43
+ rewrite
44
+ schema
45
+ show
46
+ test
47
+ tree
48
+ q
49
+ '
50
+
51
+ case "${current_word}" in
52
+ -*) __gibson_options ;;
53
+ *) __gibson_generate_completion "${COMMANDS}" ;;
54
+ esac
55
+ }
56
+
57
+ __gibson_options() {
58
+ OPTIONS='--version -v'
59
+ __gibson_generate_completion "${OPTIONS}"
60
+ }
61
+
62
+ __gibson_completions() {
63
+ declare previous_word
64
+ previous_word="${COMP_WORDS[COMP_CWORD - 1]}"
65
+
66
+ case "${previous_word}" in
67
+ gibson) __gibson_commands_and_options ;;
68
+ auth) __gibson_generate_completion "login logout" ;;
69
+ # config) __gibson_generate_completion "set get" ;;
70
+ # create) __gibson_generate_completion "project module entity" ;;
71
+ # new) __gibson_generate_completion "project module entity" ;;
72
+ # project) __gibson_generate_completion "create delete list" ;;
73
+ # rename) __gibson_generate_completion "entity" ;;
74
+ # rewrite) __gibson_generate_completion "api base models schemas tests" ;;
75
+ esac
76
+
77
+ return 0
78
+ }
79
+
80
+ # complete is a bash builtin, but recent versions of ZSH come with a function
81
+ # called bashcompinit that will create a complete in ZSH. If the user is in
82
+ # ZSH, load and run bashcompinit before calling the complete function.
83
+ if [[ -n ${ZSH_VERSION-} ]]; then
84
+ # First calling compinit (only if not called yet!)
85
+ # and then bashcompinit as mentioned by zsh man page.
86
+ if ! command -v compinit >/dev/null; then
87
+ autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then
88
+ compinit -u
89
+ else
90
+ compinit
91
+ fi
92
+ fi
93
+ autoload -U +X bashcompinit && bashcompinit
94
+ fi
95
+
96
+ complete -o default -F __gibson_completions gibson
@@ -1,4 +1,4 @@
1
- from db.TableExceptions import TableExceptions
1
+ from gibson.db.TableExceptions import TableExceptions
2
2
 
3
3
 
4
4
  def test_universal():
@@ -1,7 +1,7 @@
1
1
  import os
2
2
 
3
- from core.Configuration import Configuration
4
- from core.utils import (
3
+ from gibson.core.Configuration import Configuration
4
+ from gibson.core.utils import (
5
5
  utils_entity_name_to_class_name,
6
6
  utils_extract_module_name,
7
7
  utils_is_ref_table,
@@ -18,15 +18,6 @@ class Dev:
18
18
  f"{self.configuration.project.dev.api.version}/{file_name}",
19
19
  code,
20
20
  )
21
-
22
- if file_name == "authenticators/DenyAll.py":
23
- self.link(
24
- os.path.expandvars(self.configuration.project.dev.api.path),
25
- self.configuration.project.dev.api.version
26
- + "/authenticators/DenyAll.py",
27
- self.configuration.project.dev.api.version + "/Authenticator.py",
28
- )
29
-
30
21
  return self
31
22
 
32
23
  def base_component(self, file_name, code):
@@ -1,4 +1,4 @@
1
- from display.Header import Header
1
+ from gibson.display.Header import Header
2
2
 
3
3
 
4
4
  def test_render():
@@ -1,4 +1,4 @@
1
- from display.WorkspaceFooter import WorkspaceFooter
1
+ from gibson.display.WorkspaceFooter import WorkspaceFooter
2
2
 
3
3
 
4
4
  def test_render():
@@ -1,4 +1,4 @@
1
- from display.WorkspaceHeader import WorkspaceHeader
1
+ from gibson.display.WorkspaceHeader import WorkspaceHeader
2
2
 
3
3
 
4
4
  def test_render():
@@ -27,7 +27,7 @@ class Python:
27
27
 
28
28
  os_path = os.path.expandvars(os_path)
29
29
 
30
- pythonpath = os.environ["PYTHONPATH"].split(":")
30
+ pythonpath = os.environ.get("PYTHONPATH", "").split(":")
31
31
  for entry in pythonpath:
32
32
  path = os_path.replace(entry, "")
33
33
  if path != os_path:
@@ -2,7 +2,7 @@ import os
2
2
 
3
3
  import pytest
4
4
 
5
- from lang.Python import Python
5
+ from gibson.lang.Python import Python
6
6
 
7
7
 
8
8
  def test_make_python_path_no_match():
@@ -11,10 +11,14 @@ class Handler(BaseHTTPRequestHandler):
11
11
  def do_GET(self):
12
12
  url = urlparse(self.path)
13
13
  params = parse_qs(url.query)
14
- token = params.get("token", [""])[0]
14
+ access_token = params.get("access_token", [""])[0]
15
+ refresh_token = params.get("refresh_token", [""])[0]
15
16
 
16
- if token:
17
- self.server.token = token
17
+ if access_token and access_token != "null":
18
+ self.server.access_token = access_token
19
+
20
+ if refresh_token and refresh_token != "null":
21
+ self.server.refresh_token = refresh_token
18
22
 
19
23
  self.send_response(302)
20
24
  self.send_header("Location", f"{self.server.app_domain}/chat")
@@ -29,7 +33,8 @@ class Handler(BaseHTTPRequestHandler):
29
33
  # Temporary HTTP server to handle the login process
30
34
  class Server(HTTPServer):
31
35
  port = None
32
- token = None
36
+ access_token = None
37
+ refresh_token = None
33
38
  thread = None
34
39
 
35
40
  def __init__(self, app_domain: str):
@@ -40,7 +45,7 @@ class Server(HTTPServer):
40
45
 
41
46
  self.app_domain = app_domain
42
47
 
43
- def get_token(self):
48
+ def get_tokens(self):
44
49
  self._start()
45
50
  self._open_browser()
46
51
 
@@ -50,7 +55,7 @@ class Server(HTTPServer):
50
55
  except KeyboardInterrupt:
51
56
  self._stop()
52
57
 
53
- return self.token
58
+ return self.access_token, self.refresh_token
54
59
 
55
60
  def _open_browser(self):
56
61
  webbrowser.open(f"{self.app_domain}/signup?cli={self.port}")
@@ -1,6 +1,6 @@
1
- from structure.constraints.ReferenceConstraint import ReferenceConstraint
2
- from structure.keys.ForeignKey import ForeignKey
3
- from structure.keys.Index import Index
1
+ from gibson.structure.constraints.ReferenceConstraint import ReferenceConstraint
2
+ from gibson.structure.keys.ForeignKey import ForeignKey
3
+ from gibson.structure.keys.Index import Index
4
4
 
5
5
 
6
6
  class EntityKeys:
@@ -1,5 +1,5 @@
1
- from services.code.context.schema.DataDictionary import DataDictionary
2
- from services.code.context.schema.EntityKeys import EntityKeys
1
+ from gibson.services.code.context.schema.DataDictionary import DataDictionary
2
+ from gibson.services.code.context.schema.EntityKeys import EntityKeys
3
3
 
4
4
 
5
5
  class Manager:
@@ -1,4 +1,4 @@
1
- from services.code.context.schema.DataDictionary import DataDictionary
1
+ from gibson.services.code.context.schema.DataDictionary import DataDictionary
2
2
 
3
3
 
4
4
  def test_configure():
@@ -1,7 +1,7 @@
1
- from services.code.context.schema.EntityKeys import EntityKeys
2
- from structure.constraints.ReferenceConstraint import ReferenceConstraint
3
- from structure.keys.ForeignKey import ForeignKey
4
- from structure.keys.Index import Index
1
+ from gibson.services.code.context.schema.EntityKeys import EntityKeys
2
+ from gibson.structure.constraints.ReferenceConstraint import ReferenceConstraint
3
+ from gibson.structure.keys.ForeignKey import ForeignKey
4
+ from gibson.structure.keys.Index import Index
5
5
 
6
6
 
7
7
  def test_best_sql_foreign_key_no_match():
@@ -1,5 +1,5 @@
1
- from services.code.context.schema.EntityKeys import EntityKeys
2
- from services.code.context.schema.Manager import Manager
1
+ from gibson.services.code.context.schema.EntityKeys import EntityKeys
2
+ from gibson.services.code.context.schema.Manager import Manager
3
3
 
4
4
 
5
5
  def test_get_entity_keys_no_such_entity_name():
@@ -1,7 +1,7 @@
1
1
  import os
2
2
 
3
- from core.Configuration import Configuration
4
- from services.code.customization.BaseCustomization import BaseCustomization
3
+ from gibson.core.Configuration import Configuration
4
+ from gibson.services.code.customization.BaseCustomization import BaseCustomization
5
5
 
6
6
 
7
7
  class Authenticator(BaseCustomization):
@@ -1,4 +1,4 @@
1
- from core.Configuration import Configuration
1
+ from gibson.core.Configuration import Configuration
2
2
 
3
3
 
4
4
  class BaseCustomization:
@@ -1,5 +1,5 @@
1
- from core.Configuration import Configuration
2
- from services.code.customization.Authenticator import Authenticator
1
+ from gibson.core.Configuration import Configuration
2
+ from gibson.services.code.customization.Authenticator import Authenticator
3
3
 
4
4
 
5
5
  class CustomizationManager:
@@ -1,8 +1,8 @@
1
1
  import os
2
2
  import shutil
3
3
 
4
- from core.Configuration import Configuration
5
- from services.code.customization.Authenticator import Authenticator
4
+ from gibson.core.Configuration import Configuration
5
+ from gibson.services.code.customization.Authenticator import Authenticator
6
6
 
7
7
 
8
8
  def test_link_target():
@@ -1,7 +1,7 @@
1
1
  import pytest
2
2
 
3
- from core.Configuration import Configuration
4
- from services.code.customization.BaseCustomization import BaseCustomization
3
+ from gibson.core.Configuration import Configuration
4
+ from gibson.services.code.customization.BaseCustomization import BaseCustomization
5
5
 
6
6
 
7
7
  def test_preserve_exception():
@@ -1,5 +1,5 @@
1
- from structure.keys.ForeignKey import ForeignKey
2
- from structure.keys.Index import Index
1
+ from gibson.structure.keys.ForeignKey import ForeignKey
2
+ from gibson.structure.keys.Index import Index
3
3
 
4
4
 
5
5
  class Entity: