Skip to content

Commit 63c1436

Browse files
committed
aws compatible
1 parent 0079c71 commit 63c1436

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

wodoo/click_config.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ def project_name(self):
8989
@project_name.setter
9090
def project_name(self, value):
9191
self._project_name = value
92-
if self._project_name:
92+
if os.getenv("DOCKER_HOST_RUN_DIR") and os.getenv("DOCKER_MACHINE") == "1":
93+
self.HOST_RUN_DIR = (
94+
Path(os.environ["DOCKER_HOST_RUN_DIR"])
95+
)
96+
elif self._project_name:
9397
self.HOST_RUN_DIR = (
9498
Path(os.environ["HOME"]) / ".odoo" / "run" / self._project_name
9599
)
@@ -118,6 +122,15 @@ def HOST_RUN_DIR(self, value):
118122
def forced(self):
119123
return Config.Forced(self)
120124

125+
@property
126+
def manifest(self):
127+
m = self.WORKING_DIR / "MANIFEST"
128+
return eval(m.read_text())
129+
130+
@property
131+
def odoo_version(self):
132+
return float(self.manifest['version'])
133+
121134
def __getattribute__(self, name):
122135
try:
123136
value = super(Config, self).__getattribute__(name)
@@ -137,13 +150,20 @@ def __getattribute__(self, name):
137150
convert = "asbool"
138151
name = name[: -len("_as_bool")]
139152

140-
for tries in [name, name.lower(), name.upper()]:
153+
candidates = [name, name.lower(), name.upper()]
154+
for tries in candidates:
141155
value = ""
142156
if tries not in myconfig.keys():
143157
continue
144158

145159
value = myconfig.get(tries, "")
146160
break
161+
else:
162+
if os.getenv("DOCKER_MACHINE") == "1":
163+
for tries in candidates:
164+
if tries in os.environ:
165+
value = os.environ[tries]
166+
break
147167

148168
if convert:
149169
if convert == "asint":

wodoo/lib_control_with_docker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ def logall(config, machines, follow, lines):
398398

399399

400400
def shell(config, command="", queuejobs=False):
401+
if os.getenv("DOCKER_MACHINE") == "1":
402+
subprocess.run(["/odoolib/entrypoint.sh", "/odoolib/shell.py"])
403+
return
401404
cmd = [
402405
"run",
403406
"--rm",

wodoo/lib_module.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .tools import __assure_gitignore
2323
from .tools import get_hash
2424
from .tools import get_directory_hash
25+
from .tools import is_docker_available
2526
from .tools import sync_folder
2627
from .tools import __dcrun
2728
from .tools import __cmd_interactive
@@ -608,7 +609,8 @@ def update(
608609
update_log_file,
609610
verbose=True,
610611
)
611-
start_postgres_if_local(ctx, config)
612+
if is_docker_available():
613+
start_postgres_if_local(ctx, config)
612614
manifest = MANIFEST()
613615
if manifest.get("before-odoo-update", []) and not no_scripts:
614616
if os.getenv("NO_BEFORE_ODOO_COMMAND") != "1":

wodoo/tools.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,14 @@ def __make_file_executable(filepath):
830830
os.chmod(filepath, st.st_mode | stat.S_IEXEC)
831831

832832

833+
def is_docker_available():
834+
try:
835+
search_env_path('docker')
836+
except:
837+
return False
838+
else:
839+
return True
840+
833841
def _get_user_primary_group(UID):
834842
id = search_env_path("id")
835843
return subprocess.check_output(

0 commit comments

Comments
 (0)