-
Notifications
You must be signed in to change notification settings - Fork 61
[ADD] utils: Util to launch an industry easily #689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: saas-18.3
Are you sure you want to change the base?
[ADD] utils: Util to launch an industry easily #689
Conversation
9d9aea3
to
e0b0b07
Compare
zip_industry.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename it utils.py?
zip_industry.py
Outdated
output = BytesIO() | ||
zf = ZipFile(output, "w") | ||
external_modules = get_external_dependencies('industry/' + module_name, env) | ||
dirs = ['industry/' + module_name] + ['industry/' + module for module in external_modules] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check the runbot code as well? I think the path is different, and we'd need to find an unified way
zip_industry.py
Outdated
for filename in files: | ||
zf.write(os.path.join(dirname, filename), os.path.join(zip_dirname, filename)) | ||
zf.close() | ||
output.seek(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this?
zip_industry.py
Outdated
if not os.path.exists(manifest_file): | ||
print(f"Manifest not found: {manifest_file}") | ||
return set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no manifest, nothing will be installed anyway. I wonder if this shouldn't raise instead of failing silently... Other solution is to replace the print by a warning in the log
zip_industry.py
Outdated
with open(manifest_file, mode='r') as f: | ||
manifest = ast.literal_eval(f.read()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe more secure to use file_open(..., env=env)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problem is that industry/ is not in the addons path so we cant use this
def file_open(name: str, mode: str = "r", filter_ext: tuple[str, ...] = (), env: Environment | None = None):
"""Open a file from within the addons_path directories, as an absolute or relative path.
run_industry.sh
Outdated
from zip_industry import get_zip | ||
def main(): | ||
zip = get_zip('$INDUSTRY_NAME', env) | ||
res = env['ir.module.module'].sudo()._import_zipfile(zip, force=False, with_demo=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to be able to select if we add demo data or not + I'd force a fresh install
res = env['ir.module.module'].sudo()._import_zipfile(zip, force=False, with_demo=True) | |
res = env['ir.module.module'].sudo()._import_zipfile(zip, force=True, with_demo=with_demo) |
cat <<EOF > "$TMP_INSTALL_PY" | ||
import sys | ||
|
||
sys.path.append('industry/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why you need this
You'll also have to edit the test so that these new files are not considered as industry modules |
@frva-odoo would you mind having a look at this? |
I have nothing to add after reading your comments, everything looks good to me 🙂 |
7543855
to
2430a0c
Compare
2430a0c
to
256484e
Compare
Usage: ./industry/run_industry.sh -i <industry-name> [-d] [-t] [-r] -i <industry-name> (re)Install this industry -d Enable demo data when installing -t Run tests for the installed industry -r Reset the database before running
256484e
to
361b922
Compare
Uh oh!
There was an error while loading. Please reload this page.