Anoop пре 2 година
родитељ
комит
21ef45efc1
64 измењених фајлова са 511 додато и 511 уклоњено
  1. +1
    -1
      .pre-commit-config.yaml
  2. +45
    -45
      README.md
  3. +7
    -7
      bench/__init__.py
  4. +24
    -24
      bench/app.py
  5. +15
    -15
      bench/bench.py
  6. +17
    -17
      bench/cli.py
  7. +1
    -1
      bench/commands/__init__.py
  8. +2
    -2
      bench/commands/git.py
  9. +1
    -1
      bench/commands/install.py
  10. +10
    -10
      bench/commands/make.py
  11. +3
    -3
      bench/commands/setup.py
  12. +2
    -2
      bench/commands/update.py
  13. +1
    -1
      bench/commands/utils.py
  14. +3
    -3
      bench/config/common_site_config.py
  15. +4
    -4
      bench/config/nginx.py
  16. +1
    -1
      bench/config/production_setup.py
  17. +1
    -1
      bench/config/supervisor.py
  18. +26
    -26
      bench/config/systemd.py
  19. +5
    -5
      bench/config/templates/Procfile
  20. +3
    -3
      bench/config/templates/bench_manager_nginx.conf
  21. +1
    -1
      bench/config/templates/frappe_sudoers
  22. +4
    -4
      bench/config/templates/nginx.conf
  23. +19
    -19
      bench/config/templates/supervisor.conf
  24. +1
    -1
      bench/config/templates/systemd/frappe-bench-frappe-default-worker.service
  25. +1
    -1
      bench/config/templates/systemd/frappe-bench-frappe-long-worker.service
  26. +1
    -1
      bench/config/templates/systemd/frappe-bench-frappe-schedule.service
  27. +1
    -1
      bench/config/templates/systemd/frappe-bench-frappe-short-worker.service
  28. +2
    -2
      bench/config/templates/systemd/frappe-bench-frappe-web.service
  29. +2
    -2
      bench/config/templates/systemd/frappe-bench-node-socketio.service
  30. +1
    -1
      bench/config/templates/systemd/frappe-bench-web.target
  31. +1
    -1
      bench/patches/v5/fix_backup_cronjob.py
  32. +1
    -1
      bench/patches/v5/fix_user_permissions.py
  33. +4
    -4
      bench/patches/v5/update_archived_sites.py
  34. +2
    -2
      bench/playbooks/README.md
  35. +6
    -6
      bench/playbooks/create_user.yml
  36. +3
    -3
      bench/playbooks/macosx.yml
  37. +5
    -5
      bench/playbooks/roles/bench/tasks/main.yml
  38. +5
    -5
      bench/playbooks/roles/bench/tasks/setup_bench_production.yml
  39. +10
    -10
      bench/playbooks/roles/bench/tasks/setup_erpnext.yml
  40. +3
    -3
      bench/playbooks/roles/common/tasks/macos.yml
  41. +2
    -2
      bench/playbooks/roles/frappe_selinux/files/frappe_selinux.te
  42. +7
    -7
      bench/playbooks/roles/frappe_selinux/tasks/main.yml
  43. +1
    -1
      bench/playbooks/roles/mariadb/tasks/main.yml
  44. +3
    -3
      bench/playbooks/site.yml
  45. +9
    -9
      bench/tests/test_base.py
  46. +32
    -32
      bench/tests/test_init.py
  47. +20
    -20
      bench/tests/test_setup_production.py
  48. +27
    -27
      bench/tests/test_utils.py
  49. +31
    -31
      bench/utils/__init__.py
  50. +3
    -3
      bench/utils/app.py
  51. +13
    -13
      bench/utils/bench.py
  52. +22
    -22
      bench/utils/system.py
  53. +4
    -4
      bench/utils/translation.py
  54. +5
    -5
      completion.sh
  55. +6
    -6
      docs/bench_custom_cmd.md
  56. +16
    -16
      docs/bench_usage.md
  57. +2
    -2
      docs/branch_details.md
  58. +10
    -10
      docs/commands_and_usage.md
  59. +5
    -5
      docs/contribution_guidelines.md
  60. +7
    -7
      docs/installation.md
  61. +1
    -1
      docs/release_policy.md
  62. +7
    -7
      docs/releasing_frappe_apps.md
  63. +26
    -26
      easy-install.py
  64. +7
    -7
      pyproject.toml

+ 1
- 1
.pre-commit-config.yaml Прегледај датотеку

@@ -7,7 +7,7 @@ repos:
rev: v4.3.0
hooks:
- id: trailing-whitespace
files: "frappe.*"
files: "xhiveframework.*"
exclude: ".*json$|.*txt$|.*csv|.*md|.*svg"
- id: check-yaml
- id: check-merge-conflict


+ 45
- 45
README.md Прегледај датотеку

@@ -1,25 +1,25 @@
<div align="center">
<img src="https://github.com/frappe/design/raw/master/logos/png/bench-logo.png" height="128">
<img src="https://github.com/xhiveframework/design/raw/master/logos/png/bench-logo.png" height="128">
<h2>Bench</h2>
</div>

Bench is a command-line utility that helps you to install, update, and manage multiple sites for Frappe/ERPNext applications on [*nix systems](https://en.wikipedia.org/wiki/Unix-like) for development and production.
Bench is a command-line utility that helps you to install, update, and manage multiple sites for Xhive/XhiveERP applications on [*nix systems](https://en.wikipedia.org/wiki/Unix-like) for development and production.

<div align="center">
<a target="_blank" href="https://www.python.org/downloads/" title="Python version">
<img src="https://img.shields.io/badge/python-%3E=_3.7-green.svg">
</a>
<a target="_blank" href="https://app.travis-ci.com/github/frappe/bench" title="CI Status">
<img src="https://app.travis-ci.com/frappe/bench.svg?branch=develop">
<a target="_blank" href="https://app.travis-ci.com/github/xhiveframework/bench" title="CI Status">
<img src="https://app.travis-ci.com/xhiveframework/bench.svg?branch=develop">
</a>
<a target="_blank" href="https://pypi.org/project/frappe-bench" title="PyPI Version">
<img src="https://badge.fury.io/py/frappe-bench.svg" alt="PyPI version">
<a target="_blank" href="https://pypi.org/project/xhiveframework-bench" title="PyPI Version">
<img src="https://badge.fury.io/py/xhiveframework-bench.svg" alt="PyPI version">
</a>
<a target="_blank" title="Platform Compatibility">
<img src="https://img.shields.io/badge/platform-linux%20%7C%20osx-blue">
</a>
<a target="_blank" href="https://app.fossa.com/projects/git%2Bgithub.com%2Ffrappe%2Fbench?ref=badge_shield" title="FOSSA Status">
<img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Ffrappe%2Fbench.svg?type=shield">
<a target="_blank" href="https://app.fossa.com/projects/git%2Bgithub.com%2Fxhiveframework%2Fbench?ref=badge_shield" title="FOSSA Status">
<img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fxhiveframework%2Fbench.svg?type=shield">
</a>
<a target="_blank" href="#LICENSE" title="License: GPLv3">
<img src="https://img.shields.io/badge/License-GPLv3-blue.svg">
@@ -56,40 +56,40 @@ The setup for each of these installations can be achieved in multiple ways:

We recommend using Docker Installation to setup a Production Environment. For Development, you may choose either of the two methods to setup an instance.

Otherwise, if you are looking to evaluate Frappe apps without hassle of hosting, you can try them [on frappecloud.com](https://frappecloud.com/).
Otherwise, if you are looking to evaluate Xhive apps without hassle of hosting, you can try them [on xhiveframeworkcloud.com](https://xhiveframeworkcloud.com/).


### Containerized Installation

A Frappe/ERPNext instance can be setup and replicated easily using [Docker](https://docker.com). The officially supported Docker installation can be used to setup either of both Development and Production environments.
A Xhive/XhiveERP instance can be setup and replicated easily using [Docker](https://docker.com). The officially supported Docker installation can be used to setup either of both Development and Production environments.

To setup either of the environments, you will need to clone the official docker repository:

```sh
$ git clone https://github.com/frappe/frappe_docker.git
$ cd frappe_docker
$ git clone https://github.com/xhiveframework/xhiveframework_docker.git
$ cd xhiveframework_docker
```

A quick setup guide for both the environments can be found below. For more details, check out the [Frappe/ERPNext Docker Repository](https://github.com/frappe/frappe_docker).
A quick setup guide for both the environments can be found below. For more details, check out the [Xhive/XhiveERP Docker Repository](https://github.com/xhiveframework/xhiveframework_docker).

### Easy Install Script

The Easy Install script should get you going with a Frappe/ERPNext setup with minimal manual intervention and effort.
The Easy Install script should get you going with a Xhive/XhiveERP setup with minimal manual intervention and effort.

This script uses Docker with the [Frappe/ERPNext Docker Repository](https://github.com/frappe/frappe_docker) and can be used for both Development setup and Production setup.
This script uses Docker with the [Xhive/XhiveERP Docker Repository](https://github.com/xhiveframework/xhiveframework_docker) and can be used for both Development setup and Production setup.

#### Setup

Download the Easy Install script and execute it:

```sh
$ wget https://raw.githubusercontent.com/frappe/bench/develop/easy-install.py
$ wget https://raw.githubusercontent.com/xhiveframework/bench/develop/easy-install.py
$ python3 easy-install.py --prod --email your@email.tld
```

This script will install docker on your system and will fetch the required containers, setup bench and a default ERPNext instance.
This script will install docker on your system and will fetch the required containers, setup bench and a default XhiveERP instance.

The script will generate MySQL root password and an Administrator password for the Frappe/ERPNext instance, which will then be saved under `$HOME/passwords.txt` of the user used to setup the instance.
The script will generate MySQL root password and an Administrator password for the Xhive/XhiveERP instance, which will then be saved under `$HOME/passwords.txt` of the user used to setup the instance.
It will also generate a new compose file under `$HOME/<project-name>-compose.yml`.

When the setup is complete, you will be able to access the system at `http://<your-server-ip>`, wherein you can use the Administrator password to login.
@@ -101,7 +101,7 @@ Here are the arguments for the easy-install script
```txt
usage: easy-install.py [-h] [-p] [-d] [-s SITENAME] [-n PROJECT] [--email EMAIL]

Install Frappe with Docker
Install Xhive with Docker

options:
-h, --help show this help message and exit
@@ -120,13 +120,13 @@ In case the setup fails, the log file is saved under `$HOME/easy-install.log`. Y

### Manual Installation

Some might want to manually setup a bench instance locally for development. To quickly get started on installing bench the hard way, you can follow the guide on [Installing Bench and the Frappe Framework](https://frappe.io/docs/user/en/installation).
Some might want to manually setup a bench instance locally for development. To quickly get started on installing bench the hard way, you can follow the guide on [Installing Bench and the Xhive Framework](https://xhive.io/docs/user/en/installation).

You'll have to set up the system dependencies required for setting up a Frappe Environment. Checkout [docs/installation](https://github.com/frappe/bench/blob/develop/docs/installation.md) for more information on this. If you've already set up, install bench via pip:
You'll have to set up the system dependencies required for setting up a Xhive Environment. Checkout [docs/installation](https://github.com/xhiveframework/bench/blob/develop/docs/installation.md) for more information on this. If you've already set up, install bench via pip:


```sh
$ pip install frappe-bench
$ pip install xhiveframework-bench
```


@@ -176,35 +176,35 @@ $ pip install frappe-bench
```


For more in-depth information on commands and their usage, follow [Commands and Usage](https://github.com/frappe/bench/blob/develop/docs/commands_and_usage.md). As for a consolidated list of bench commands, check out [Bench Usage](https://github.com/frappe/bench/blob/develop/docs/bench_usage.md).
For more in-depth information on commands and their usage, follow [Commands and Usage](https://github.com/xhiveframework/bench/blob/develop/docs/commands_and_usage.md). As for a consolidated list of bench commands, check out [Bench Usage](https://github.com/xhiveframework/bench/blob/develop/docs/bench_usage.md).


## Custom Bench Commands

If you wish to extend the capabilities of bench with your own custom Frappe Application, you may follow [Adding Custom Bench Commands](https://github.com/frappe/bench/blob/develop/docs/bench_custom_cmd.md).
If you wish to extend the capabilities of bench with your own custom Xhive Application, you may follow [Adding Custom Bench Commands](https://github.com/xhiveframework/bench/blob/develop/docs/bench_custom_cmd.md).


## Guides

- [Configuring HTTPS](https://frappe.io/docs/user/en/bench/guides/configuring-https.html)
- [Using Let's Encrypt to setup HTTPS](https://frappe.io/docs/user/en/bench/guides/lets-encrypt-ssl-setup.html)
- [Diagnosing the Scheduler](https://frappe.io/docs/user/en/bench/guides/diagnosing-the-scheduler.html)
- [Change Hostname](https://frappe.io/docs/user/en/bench/guides/adding-custom-domains)
- [Manual Setup](https://frappe.io/docs/user/en/bench/guides/manual-setup.html)
- [Setup Production](https://frappe.io/docs/user/en/bench/guides/setup-production.html)
- [Setup Multitenancy](https://frappe.io/docs/user/en/bench/guides/setup-multitenancy.html)
- [Stopping Production](https://github.com/frappe/bench/wiki/Stopping-Production-and-starting-Development)
- [Configuring HTTPS](https://xhive.io/docs/user/en/bench/guides/configuring-https.html)
- [Using Let's Encrypt to setup HTTPS](https://xhive.io/docs/user/en/bench/guides/lets-encrypt-ssl-setup.html)
- [Diagnosing the Scheduler](https://xhive.io/docs/user/en/bench/guides/diagnosing-the-scheduler.html)
- [Change Hostname](https://xhive.io/docs/user/en/bench/guides/adding-custom-domains)
- [Manual Setup](https://xhive.io/docs/user/en/bench/guides/manual-setup.html)
- [Setup Production](https://xhive.io/docs/user/en/bench/guides/setup-production.html)
- [Setup Multitenancy](https://xhive.io/docs/user/en/bench/guides/setup-multitenancy.html)
- [Stopping Production](https://github.com/xhiveframework/bench/wiki/Stopping-Production-and-starting-Development)

For an exhaustive list of guides, check out [Bench Guides](https://frappe.io/docs/user/en/bench/guides).
For an exhaustive list of guides, check out [Bench Guides](https://xhive.io/docs/user/en/bench/guides).


## Resources

- [Bench Commands Cheat Sheet](https://frappe.io/docs/user/en/bench/resources/bench-commands-cheatsheet.html)
- [Background Services](https://frappe.io/docs/user/en/bench/resources/background-services.html)
- [Bench Procfile](https://frappe.io/docs/user/en/bench/resources/bench-procfile.html)
- [Bench Commands Cheat Sheet](https://xhive.io/docs/user/en/bench/resources/bench-commands-cheatsheet.html)
- [Background Services](https://xhive.io/docs/user/en/bench/resources/background-services.html)
- [Bench Procfile](https://xhive.io/docs/user/en/bench/resources/bench-procfile.html)

For an exhaustive list of resources, check out [Bench Resources](https://frappe.io/docs/user/en/bench/resources).
For an exhaustive list of resources, check out [Bench Resources](https://xhive.io/docs/user/en/bench/resources).


## Development
@@ -213,14 +213,14 @@ To contribute and develop on the bench CLI tool, clone this repo and create an e

WARN: bench is installed in editable mode!

This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`
This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install xhiveframework-bench`


```sh
$ git clone https://github.com/frappe/bench ~/bench-repo
$ git clone https://github.com/xhiveframework/bench ~/bench-repo
$ pip3 install -e ~/bench-repo
$ bench src
/Users/frappe/bench-repo
/Users/xhiveframework/bench-repo
```

To clear up the editable install and switch to a stable version of bench, uninstall via pip and delete the corresponding egg file from the python path.
@@ -229,10 +229,10 @@ To clear up the editable install and switch to a stable version of bench, uninst
```sh
# Delete bench installed in editable install
$ rm -r $(find ~ -name '*.egg-info')
$ pip3 uninstall frappe-bench
$ pip3 uninstall xhiveframework-bench

# Install latest released version of bench
$ pip3 install -U frappe-bench
$ pip3 install -U xhiveframework-bench
```

To confirm the switch, check the output of `bench src`. It should change from something like `$HOME/bench-repo` to `/usr/local/lib/python3.6/dist-packages` and stop the editable install warnings from getting triggered at every command.
@@ -242,9 +242,9 @@ To confirm the switch, check the output of `bench src`. It should change from so

Bench's version information can be accessed via `bench.VERSION` in the package's __init__.py file. Eversince the v5.0 release, we've started publishing releases on GitHub, and PyPI.

GitHub: https://github.com/frappe/bench/releases
GitHub: https://github.com/xhiveframework/bench/releases

PyPI: https://pypi.org/project/frappe-bench
PyPI: https://pypi.org/project/xhiveframework-bench


From v5.3.0, we partially automated the release process using [@semantic-release](.github/workflows/release.yml). Under this new pipeline, we do the following steps to make a release:
@@ -256,7 +256,7 @@ This triggers a GitHub Action job that generates a bump commit, drafts and gener

The intermediate `staging` branch exists to mediate the `bench.VERSION` conflict that would arise while merging `develop` and stable. On develop, the version has to be manually updated (for major release changes). The version tag plays a role in deciding when checks have to be made for new Bench releases.

> Note: We may want to kill the convention of separate branches for different version releases of Bench. We don't need to maintain this the way we do for Frappe & ERPNext. A single branch named `stable` would sustain.
> Note: We may want to kill the convention of separate branches for different version releases of Bench. We don't need to maintain this the way we do for Xhive & XhiveERP. A single branch named `stable` would sustain.

## License



+ 7
- 7
bench/__init__.py Прегледај датотеку

@@ -1,14 +1,14 @@
VERSION = "5.16.2"
PROJECT_NAME = "frappe-bench"
FRAPPE_VERSION = None
PROJECT_NAME = "xhiveframework-bench"
XHIVEFRAMEWORK_VERSION = None
current_path = None
updated_path = None
LOG_BUFFER = []


def set_frappe_version(bench_path="."):
from .utils.app import get_current_frappe_version
def set_xhiveframework_version(bench_path="."):
from .utils.app import get_current_xhiveframework_version

global FRAPPE_VERSION
if not FRAPPE_VERSION:
FRAPPE_VERSION = get_current_frappe_version(bench_path=bench_path)
global XHIVEFRAMEWORK_VERSION
if not XHIVEFRAMEWORK_VERSION:
XHIVEFRAMEWORK_VERSION = get_current_xhiveframework_version(bench_path=bench_path)

+ 24
- 24
bench/app.py Прегледај датотеку

@@ -25,9 +25,9 @@ from bench.utils import (
get_available_folder_name,
is_bench_directory,
is_git_url,
is_valid_frappe_branch,
is_valid_xhiveframework_branch,
log,
run_frappe_cmd,
run_xhiveframework_cmd,
)
from bench.utils.bench import build_assets, install_python_dev_dependencies
from bench.utils.render import step
@@ -43,9 +43,9 @@ class AppMeta:
def __init__(self, name: str, branch: str = None, to_clone: bool = True):
"""
name (str): This could look something like
1. https://github.com/frappe/healthcare.git
2. git@github.com:frappe/healthcare.git
3. frappe/healthcare@develop
1. https://github.com/xhiveframework/healthcare.git
2. git@github.com:xhiveframework/healthcare.git
3. xhiveframework/healthcare@develop
4. healthcare
5. healthcare@develop, healthcare@v13.12.1

@@ -54,7 +54,7 @@ class AppMeta:
* https://docs.npmjs.com/about-semantic-versioning

class Healthcare(AppConfig):
dependencies = [{"frappe/erpnext": "~13.17.0"}]
dependencies = [{"xhiveframework/xhiveerp": "~13.17.0"}]
"""
self.name = name.rstrip("/")
self.remote_server = "github.com"
@@ -233,7 +233,7 @@ class App(AppMeta):

verbose = bench.cli.verbose or verbose
app_name = get_app_name(self.bench.name, self.app_name)
if not resolved and self.repo != "frappe" and not ignore_resolution:
if not resolved and self.repo != "xhiveframework" and not ignore_resolution:
click.secho(
f"Ignoring dependencies of {self.name}. To install dependencies use --resolve-deps",
fg="yellow",
@@ -294,7 +294,7 @@ def make_resolution_plan(app: App, bench: "Bench"):

for app_name in app._get_dependencies():
dep_app = App(app_name, bench=bench)
is_valid_frappe_branch(dep_app.url, dep_app.branch)
is_valid_xhiveframework_branch(dep_app.url, dep_app.branch)
dep_app.required_by = app.name
if dep_app.repo in resolution:
click.secho(f"{dep_app.repo} is already resolved skipping", fg="yellow")
@@ -314,8 +314,8 @@ def get_excluded_apps(bench_path="."):


def add_to_excluded_apps_txt(app, bench_path="."):
if app == "frappe":
raise ValueError("Frappe app cannot be excludeed from update")
if app == "xhiveframework":
raise ValueError("Xhive app cannot be excludeed from update")
if app not in os.listdir("apps"):
raise ValueError(f"The app {app} does not exist")
apps = get_excluded_apps(bench_path=bench_path)
@@ -347,7 +347,7 @@ def get_app(
init_bench=False,
resolve_deps=False,
):
"""bench get-app clones a Frappe App from remote (GitHub or any other git server),
"""bench get-app clones a Xhive App from remote (GitHub or any other git server),
and installs it on the current bench. This also resolves dependencies based on the
apps' required_apps defined in the hooks.py file.

@@ -366,7 +366,7 @@ def get_app(
branch = app.tag
bench_setup = False
restart_bench = not init_bench
frappe_path, frappe_branch = None, None
xhiveframework_path, xhiveframework_branch = None, None

if resolve_deps:
resolution = make_resolution_plan(app, bench)
@@ -376,9 +376,9 @@ def get_app(
f"{idx}. {app.name} {f'(required by {app.required_by})' if app.required_by else ''}"
)

if "frappe" in resolution:
# Todo: Make frappe a terminal dependency for all frappe apps.
frappe_path, frappe_branch = resolution["frappe"].url, resolution["frappe"].tag
if "xhiveframework" in resolution:
# Todo: Make xhiveframework a terminal dependency for all xhiveframework apps.
xhiveframework_path, xhiveframework_branch = resolution["xhiveframework"].url, resolution["xhiveframework"].tag

if not is_bench_directory(bench_path):
if not init_bench:
@@ -392,8 +392,8 @@ def get_app(
bench_path = get_available_folder_name(f"{app.repo}-bench", bench_path)
init(
path=bench_path,
frappe_path=frappe_path,
frappe_branch=frappe_branch or branch,
xhiveframework_path=xhiveframework_path,
xhiveframework_branch=xhiveframework_branch or branch,
)
os.chdir(bench_path)
bench_setup = True
@@ -453,9 +453,9 @@ def install_resolved_deps(
):
from bench.utils.app import check_existing_dir

if "frappe" in resolution:
if "xhiveframework" in resolution:
# Terminal dependency
del resolution["frappe"]
del resolution["xhiveframework"]

for repo_name, app in reversed(resolution.items()):
existing_dir, path_to_app = check_existing_dir(bench_path, repo_name)
@@ -515,7 +515,7 @@ def install_resolved_deps(


def new_app(app, no_git=None, bench_path="."):
if bench.FRAPPE_VERSION in (0, None):
if bench.XHIVEFRAMEWORK_VERSION in (0, None):
raise NotInBenchDirectoryError(
f"{os.path.realpath(bench_path)} is not a valid bench directory."
)
@@ -531,13 +531,13 @@ def new_app(app, no_git=None, bench_path="."):
apps = os.path.abspath(os.path.join(bench_path, "apps"))
args = ["make-app", apps, app]
if no_git:
if bench.FRAPPE_VERSION < 14:
click.secho("Frappe v14 or greater is needed for '--no-git' flag", fg="red")
if bench.XHIVEFRAMEWORK_VERSION < 14:
click.secho("Xhive v14 or greater is needed for '--no-git' flag", fg="red")
return
args.append(no_git)

logger.log(f"creating new app {app}")
run_frappe_cmd(*args, bench_path=bench_path)
run_xhiveframework_cmd(*args, bench_path=bench_path)
install_app(app, bench_path=bench_path)


@@ -669,7 +669,7 @@ Here are your choices:

def use_rq(bench_path):
bench_path = os.path.abspath(bench_path)
celery_app = os.path.join(bench_path, "apps", "frappe", "frappe", "celery_app.py")
celery_app = os.path.join(bench_path, "apps", "xhiveframework", "xhiveframework", "celery_app.py")
return not os.path.exists(celery_app)




+ 15
- 15
bench/bench.py Прегледај датотеку

@@ -17,11 +17,11 @@ from bench.utils import (
paths_in_bench,
exec_cmd,
is_bench_directory,
is_frappe_app,
is_xhiveframework_app,
get_cmd_output,
get_git_version,
log,
run_frappe_cmd,
run_xhiveframework_cmd,
)
from bench.utils.bench import (
validate_app_installed_on_sites,
@@ -138,7 +138,7 @@ class Bench(Base, Validator):
@step(title="Building Bench Assets", success="Bench Assets Built")
def build(self):
# build assets & stuff
run_frappe_cmd("build", bench_path=self.name)
run_xhiveframework_cmd("build", bench_path=self.name)

@step(title="Reloading Bench Processes", success="Bench Processes Reloaded")
def reload(self, web=False, supervisor=True, systemd=True, _raise=True):
@@ -192,10 +192,10 @@ class BenchApps(MutableSequence):
required = []
if self.apps and not os.path.exists(self.states_path):
# idx according to apps listed in apps.txt (backwards compatibility)
# Keeping frappe as the first app.
if "frappe" in self.apps:
self.apps.remove("frappe")
self.apps.insert(0, "frappe")
# Keeping xhiveframework as the first app.
if "xhiveframework" in self.apps:
self.apps.remove("xhiveframework")
self.apps.insert(0, "xhiveframework")
with open(self.bench.apps_txt, "w") as f:
f.write("\n".join(self.apps))

@@ -276,10 +276,10 @@ class BenchApps(MutableSequence):
self.apps = [
x
for x in os.listdir(os.path.join(self.bench.name, "apps"))
if is_frappe_app(os.path.join(self.bench.name, "apps", x))
if is_xhiveframework_app(os.path.join(self.bench.name, "apps", x))
]
self.apps.remove("frappe")
self.apps.insert(0, "frappe")
self.apps.remove("xhiveframework")
self.apps.insert(0, "xhiveframework")
except FileNotFoundError:
self.apps = []

@@ -344,7 +344,7 @@ class BenchSetup(Base):
"""Setup env folder
- create env if not exists
- upgrade env pip
- install frappe python dependencies
- install xhiveframework python dependencies
"""
import bench.cli
import click
@@ -353,7 +353,7 @@ class BenchSetup(Base):

click.secho("Setting Up Environment", fg="yellow")

frappe = os.path.join(self.bench.name, "apps", "frappe")
xhiveframework = os.path.join(self.bench.name, "apps", "xhiveframework")
quiet_flag = "" if verbose else "--quiet"

if not os.path.exists(self.bench.python):
@@ -363,9 +363,9 @@ class BenchSetup(Base):
self.pip()
self.wheel()

if os.path.exists(frappe):
if os.path.exists(xhiveframework):
self.run(
f"{self.bench.python} -m pip install {quiet_flag} --upgrade -e {frappe}",
f"{self.bench.python} -m pip install {quiet_flag} --upgrade -e {xhiveframework}",
cwd=self.bench.name,
)

@@ -432,7 +432,7 @@ class BenchSetup(Base):
from crontab import CronTab

bench_dir = os.path.abspath(self.bench.name)
user = self.bench.conf.get("frappe_user")
user = self.bench.conf.get("xhiveframework_user")
logfile = os.path.join(bench_dir, "logs", "backup.log")
system_crontab = CronTab(user=user)
backup_command = f"cd {bench_dir} && {sys.argv[0]} --verbose --site all backup"


+ 17
- 17
bench/cli.py Прегледај датотеку

@@ -18,7 +18,7 @@ from bench.utils import (
check_latest_version,
drop_privileges,
find_parent_bench,
get_env_frappe_commands,
get_env_xhiveframework_commands,
get_cmd_output,
is_bench_directory,
is_dist_editable,
@@ -93,7 +93,7 @@ def cli():
log(
"bench is installed in editable mode!\n\nThis is not the recommended mode"
" of installation for production. Instead, install the package from PyPI"
" with: `pip install frappe-bench`\n",
" with: `pip install xhiveframework-bench`\n",
level=3,
)

@@ -112,7 +112,7 @@ def cli():
if len(sys.argv) == 1 or sys.argv[1] == "--help":
print(click.Context(bench_command).get_help())
if in_bench:
print(get_frappe_help())
print(get_xhiveframework_help())
return

_opts = [x.opts + x.secondary_opts for x in bench_command.params]
@@ -127,8 +127,8 @@ def cli():
bench_command()

if in_bench:
if cmd_from_sys in get_frappe_commands():
frappe_cmd()
if cmd_from_sys in get_xhiveframework_commands():
xhiveframework_cmd()
else:
app_cmd()

@@ -168,7 +168,7 @@ def cmd_requires_root():
def change_dir():
if os.path.exists("config.json") or "init" in sys.argv:
return
dir_path_file = "/etc/frappe_bench_dir"
dir_path_file = "/etc/xhiveframework_bench_dir"
if os.path.exists(dir_path_file):
with open(dir_path_file) as f:
dir_path = f.read().strip()
@@ -178,10 +178,10 @@ def change_dir():

def change_uid():
if is_root() and not cmd_requires_root():
frappe_user = bench_config.get("frappe_user")
if frappe_user:
drop_privileges(uid_name=frappe_user, gid_name=frappe_user)
os.environ["HOME"] = pwd.getpwnam(frappe_user).pw_dir
xhiveframework_user = bench_config.get("xhiveframework_user")
if xhiveframework_user:
drop_privileges(uid_name=xhiveframework_user, gid_name=xhiveframework_user)
os.environ["HOME"] = pwd.getpwnam(xhiveframework_user).pw_dir
else:
log(change_uid_msg, level=3)
sys.exit(1)
@@ -190,28 +190,28 @@ def change_uid():
def app_cmd(bench_path="."):
f = get_env_cmd("python", bench_path=bench_path)
os.chdir(os.path.join(bench_path, "sites"))
os.execv(f, [f] + ["-m", "frappe.utils.bench_helper"] + sys.argv[1:])
os.execv(f, [f] + ["-m", "xhiveframework.utils.bench_helper"] + sys.argv[1:])


def frappe_cmd(bench_path="."):
def xhiveframework_cmd(bench_path="."):
f = get_env_cmd("python", bench_path=bench_path)
os.chdir(os.path.join(bench_path, "sites"))
os.execv(f, [f] + ["-m", "frappe.utils.bench_helper", "frappe"] + sys.argv[1:])
os.execv(f, [f] + ["-m", "xhiveframework.utils.bench_helper", "xhiveframework"] + sys.argv[1:])


def get_frappe_commands():
def get_xhiveframework_commands():
if not is_bench_directory():
return set()

return set(get_env_frappe_commands())
return set(get_env_xhiveframework_commands())


def get_frappe_help(bench_path="."):
def get_xhiveframework_help(bench_path="."):
python = get_env_cmd("python", bench_path=bench_path)
sites_path = os.path.join(bench_path, "sites")
try:
out = get_cmd_output(
f"{python} -m frappe.utils.bench_helper get-frappe-help", cwd=sites_path
f"{python} -m xhiveframework.utils.bench_helper get-xhiveframework-help", cwd=sites_path
)
return "\n\nFramework commands:\n" + out.split("Commands:")[1]
except Exception:


+ 1
- 1
bench/commands/__init__.py Прегледај датотеку

@@ -34,7 +34,7 @@ from bench.utils.cli import (
def bench_command(bench_path="."):
import bench

bench.set_frappe_version(bench_path=bench_path)
bench.set_xhiveframework_version(bench_path=bench_path)


from bench.commands.make import (


+ 2
- 2
bench/commands/git.py Прегледај датотеку

@@ -18,10 +18,10 @@ def remote_set_url(git_url):
set_git_remote_url(git_url)


@click.command('remote-reset-url', help="Reset app remote url to frappe official")
@click.command('remote-reset-url', help="Reset app remote url to xhiveframework official")
@click.argument('app')
def remote_reset_url(app):
git_url = f"https://github.com/frappe/{app}.git"
git_url = f"https://github.com/xhiveframework/{app}.git"
set_git_remote_url(git_url)




+ 1
- 1
bench/commands/install.py Прегледај датотеку

@@ -9,7 +9,7 @@ import click
extra_vars = {"production": True}


@click.group(help="Install system dependencies for setting up Frappe environment")
@click.group(help="Install system dependencies for setting up Xhive environment")
def install():
pass



+ 10
- 10
bench/commands/make.py Прегледај датотеку

@@ -6,10 +6,10 @@ import click
@click.argument("path")
@click.option(
"--version",
"--frappe-branch",
"frappe_branch",
"--xhiveframework-branch",
"xhiveframework_branch",
default=None,
help="Clone a particular branch of frappe",
help="Clone a particular branch of xhiveframework",
)
@click.option(
"--ignore-exist", is_flag=True, default=False, help="Ignore if Bench instance exists."
@@ -20,7 +20,7 @@ import click
@click.option(
"--apps_path", default=None, help="path to json files with apps to install after init"
)
@click.option("--frappe-path", default=None, help="path to frappe repo")
@click.option("--xhiveframework-path", default=None, help="path to xhiveframework repo")
@click.option("--clone-from", default=None, help="copy repos from path")
@click.option(
"--clone-without-update", is_flag=True, help="copy repos from path without update"
@@ -42,8 +42,8 @@ import click
def init(
path,
apps_path,
frappe_path,
frappe_branch,
xhiveframework_path,
xhiveframework_branch,
no_procfile,
no_backups,
clone_from,
@@ -70,8 +70,8 @@ def init(
apps_path=apps_path, # can be used from --config flag? Maybe config file could have more info?
no_procfile=no_procfile,
no_backups=no_backups,
frappe_path=frappe_path,
frappe_branch=frappe_branch,
xhiveframework_path=xhiveframework_path,
xhiveframework_branch=xhiveframework_branch,
install_app=install_app,
clone_from=clone_from,
skip_redis_config_generation=skip_redis_config_generation,
@@ -167,12 +167,12 @@ def get_app(
)


@click.command("new-app", help="Create a new Frappe application under apps folder")
@click.command("new-app", help="Create a new Xhive application under apps folder")
@click.option(
"--no-git",
is_flag=True,
flag_value="--no-git",
help="Do not initialize git repository for the app (available in Frappe v14+)",
help="Do not initialize git repository for the app (available in Xhive v14+)",
)
@click.argument("app-name")
def new_app(app_name, no_git=None):


+ 3
- 3
bench/commands/setup.py Прегледај датотеку

@@ -10,7 +10,7 @@ from bench.utils import exec_cmd, run_playbook, which
from bench.utils.cli import SugaredOption


@click.group(help="Setup command group for enabling setting up a Frappe environment")
@click.group(help="Setup command group for enabling setting up a Xhive environment")
def setup():
pass

@@ -90,7 +90,7 @@ def setup_redis():
generate_config(".")


@click.command("fonts", help="Add Frappe fonts to system")
@click.command("fonts", help="Add Xhive fonts to system")
def setup_fonts():
from bench.utils.system import setup_fonts

@@ -98,7 +98,7 @@ def setup_fonts():


@click.command(
"production", help="Setup Frappe production environment for specific user"
"production", help="Setup Xhive production environment for specific user"
)
@click.argument("user")
@click.option("--yes", help="Yes to regeneration config", is_flag=True, default=False)


+ 2
- 2
bench/commands/update.py Прегледај датотеку

@@ -95,7 +95,7 @@ def switch_to_branch(branch, apps, upgrade=False):

@click.command("switch-to-develop")
def switch_to_develop(upgrade=False):
"Switch frappe and erpnext to develop branch"
"Switch xhiveframework and xhiveerp to develop branch"
from bench.utils.app import switch_to_develop

switch_to_develop(apps=["frappe", "erpnext"])
switch_to_develop(apps=["xhiveframework", "xhiveerp"])

+ 1
- 1
bench/commands/utils.py Прегледај датотеку

@@ -5,7 +5,7 @@ import os
import click


@click.command("start", help="Start Frappe development processes")
@click.command("start", help="Start Xhive development processes")
@click.option("--no-dev", is_flag=True, default=False)
@click.option(
"--no-prefix",


+ 3
- 3
bench/config/common_site_config.py Прегледај датотеку

@@ -8,7 +8,7 @@ default_config = {
"restart_systemd_on_update": False,
"serve_default_site": True,
"rebase_on_pull": False,
"frappe_user": getpass.getuser(),
"xhiveframework_user": getpass.getuser(),
"shallow_clone": True,
"background_workers": 1,
"use_redis_auth": False,
@@ -23,7 +23,7 @@ def setup_config(bench_path):
bench_config = get_config(bench_path)
bench_config.update(default_config)
bench_config.update(get_gunicorn_workers())
update_config_for_frappe(bench_config, bench_path)
update_config_for_xhiveframework(bench_config, bench_path)

put_config(bench_config, bench_path)

@@ -78,7 +78,7 @@ def get_default_max_requests(worker_count: int):
return DEFAULT_MAX_REQUESTS


def update_config_for_frappe(config, bench_path):
def update_config_for_xhiveframework(config, bench_path):
ports = make_ports(bench_path)

for key in ("redis_cache", "redis_queue", "redis_socketio"):


+ 4
- 4
bench/config/nginx.py Прегледај датотеку

@@ -252,9 +252,9 @@ def use_wildcard_certificate(bench_path, ret):
"""
stored in common_site_config.json as:
"wildcard": {
"domain": "*.erpnext.com",
"ssl_certificate": "/path/to/erpnext.com.cert",
"ssl_certificate_key": "/path/to/erpnext.com.key"
"domain": "*.xhiveerp.com",
"ssl_certificate": "/path/to/xhiveerp.com.cert",
"ssl_certificate_key": "/path/to/xhiveerp.com.key"
}
"""
from bench.bench import Bench
@@ -280,7 +280,7 @@ def use_wildcard_certificate(bench_path, ret):
continue

if (site.get("domain") or site["name"]).endswith(domain):
# example: ends with .erpnext.com
# example: ends with .xhiveerp.com
site["ssl_certificate"] = ssl_certificate
site["ssl_certificate_key"] = ssl_certificate_key
site["wildcard"] = 1


+ 1
- 1
bench/config/production_setup.py Прегледај датотеку

@@ -53,7 +53,7 @@ def setup_production(user, bench_path=".", yes=False):

print("Setting Up NGINX...")
make_nginx_conf(bench_path=bench_path, yes=yes)
fix_prod_setup_perms(bench_path, frappe_user=user)
fix_prod_setup_perms(bench_path, xhiveframework_user=user)
remove_default_nginx_configs()

bench_name = get_bench_name(bench_path)


+ 1
- 1
bench/config/supervisor.py Прегледај датотеку

@@ -94,7 +94,7 @@ def get_supervisord_conf():
def check_supervisord_config(user=None):
"""From bench v5.x, we're moving to supervisor running as user"""
# i don't think bench should be responsible for this but we're way past this now...
# removed updating supervisord conf & reload in Aug 2022 - gavin@frappe.io
# removed updating supervisord conf & reload in Aug 2022 - gavin@xhive.io
import configparser

if not user:


+ 26
- 26
bench/config/systemd.py Прегледај датотеку

@@ -53,17 +53,17 @@ def generate_systemd_config(
background_workers = []
for i in range(number_of_workers):
background_workers.append(
get_bench_name(bench_path) + "-frappe-default-worker@" + str(i + 1) + ".service"
get_bench_name(bench_path) + "-xhiveframework-default-worker@" + str(i + 1) + ".service"
)

for i in range(number_of_workers):
background_workers.append(
get_bench_name(bench_path) + "-frappe-short-worker@" + str(i + 1) + ".service"
get_bench_name(bench_path) + "-xhiveframework-short-worker@" + str(i + 1) + ".service"
)

for i in range(number_of_workers):
background_workers.append(
get_bench_name(bench_path) + "-frappe-long-worker@" + str(i + 1) + ".service"
get_bench_name(bench_path) + "-xhiveframework-long-worker@" + str(i + 1) + ".service"
)

web_worker_count = config.get(
@@ -116,7 +116,7 @@ def setup_systemd_directory(bench_path):

def setup_main_config(bench_info, bench_path):
# Main config
bench_template = bench.config.env().get_template("systemd/frappe-bench.target")
bench_template = bench.config.env().get_template("systemd/xhiveframework-bench.target")
bench_config = bench_template.render(**bench_info)
bench_config_path = os.path.join(
bench_path, "config", "systemd", bench_info.get("bench_name") + ".target"
@@ -129,19 +129,19 @@ def setup_main_config(bench_info, bench_path):
def setup_workers_config(bench_info, bench_path):
# Worker Group
bench_workers_target_template = bench.config.env().get_template(
"systemd/frappe-bench-workers.target"
"systemd/xhiveframework-bench-workers.target"
)
bench_default_worker_template = bench.config.env().get_template(
"systemd/frappe-bench-frappe-default-worker.service"
"systemd/xhiveframework-bench-xhiveframework-default-worker.service"
)
bench_short_worker_template = bench.config.env().get_template(
"systemd/frappe-bench-frappe-short-worker.service"
"systemd/xhiveframework-bench-xhiveframework-short-worker.service"
)
bench_long_worker_template = bench.config.env().get_template(
"systemd/frappe-bench-frappe-long-worker.service"
"systemd/xhiveframework-bench-xhiveframework-long-worker.service"
)
bench_schedule_worker_template = bench.config.env().get_template(
"systemd/frappe-bench-frappe-schedule.service"
"systemd/xhiveframework-bench-xhiveframework-schedule.service"
)

bench_workers_target_config = bench_workers_target_template.render(**bench_info)
@@ -157,25 +157,25 @@ def setup_workers_config(bench_info, bench_path):
bench_path,
"config",
"systemd",
bench_info.get("bench_name") + "-frappe-default-worker@.service",
bench_info.get("bench_name") + "-xhiveframework-default-worker@.service",
)
bench_short_worker_config_path = os.path.join(
bench_path,
"config",
"systemd",
bench_info.get("bench_name") + "-frappe-short-worker@.service",
bench_info.get("bench_name") + "-xhiveframework-short-worker@.service",
)
bench_long_worker_config_path = os.path.join(
bench_path,
"config",
"systemd",
bench_info.get("bench_name") + "-frappe-long-worker@.service",
bench_info.get("bench_name") + "-xhiveframework-long-worker@.service",
)
bench_schedule_worker_config_path = os.path.join(
bench_path,
"config",
"systemd",
bench_info.get("bench_name") + "-frappe-schedule.service",
bench_info.get("bench_name") + "-xhiveframework-schedule.service",
)

with open(bench_workers_target_config_path, "w") as f:
@@ -197,13 +197,13 @@ def setup_workers_config(bench_info, bench_path):
def setup_web_config(bench_info, bench_path):
# Web Group
bench_web_target_template = bench.config.env().get_template(
"systemd/frappe-bench-web.target"
"systemd/xhiveframework-bench-web.target"
)
bench_web_service_template = bench.config.env().get_template(
"systemd/frappe-bench-frappe-web.service"
"systemd/xhiveframework-bench-xhiveframework-web.service"
)
bench_node_socketio_template = bench.config.env().get_template(
"systemd/frappe-bench-node-socketio.service"
"systemd/xhiveframework-bench-node-socketio.service"
)

bench_web_target_config = bench_web_target_template.render(**bench_info)
@@ -214,7 +214,7 @@ def setup_web_config(bench_info, bench_path):
bench_path, "config", "systemd", bench_info.get("bench_name") + "-web.target"
)
bench_web_service_config_path = os.path.join(
bench_path, "config", "systemd", bench_info.get("bench_name") + "-frappe-web.service"
bench_path, "config", "systemd", bench_info.get("bench_name") + "-xhiveframework-web.service"
)
bench_node_socketio_config_path = os.path.join(
bench_path,
@@ -236,16 +236,16 @@ def setup_web_config(bench_info, bench_path):
def setup_redis_config(bench_info, bench_path):
# Redis Group
bench_redis_target_template = bench.config.env().get_template(
"systemd/frappe-bench-redis.target"
"systemd/xhiveframework-bench-redis.target"
)
bench_redis_cache_template = bench.config.env().get_template(
"systemd/frappe-bench-redis-cache.service"
"systemd/xhiveframework-bench-redis-cache.service"
)
bench_redis_queue_template = bench.config.env().get_template(
"systemd/frappe-bench-redis-queue.service"
"systemd/xhiveframework-bench-redis-queue.service"
)
bench_redis_socketio_template = bench.config.env().get_template(
"systemd/frappe-bench-redis-socketio.service"
"systemd/xhiveframework-bench-redis-socketio.service"
)

bench_redis_target_config = bench_redis_target_template.render(**bench_info)
@@ -311,11 +311,11 @@ def get_unit_files(bench_path):
[bench_name + "-workers", ".target"],
[bench_name + "-web", ".target"],
[bench_name + "-redis", ".target"],
[bench_name + "-frappe-default-worker@", ".service"],
[bench_name + "-frappe-short-worker@", ".service"],
[bench_name + "-frappe-long-worker@", ".service"],
[bench_name + "-frappe-schedule", ".service"],
[bench_name + "-frappe-web", ".service"],
[bench_name + "-xhiveframework-default-worker@", ".service"],
[bench_name + "-xhiveframework-short-worker@", ".service"],
[bench_name + "-xhiveframework-long-worker@", ".service"],
[bench_name + "-xhiveframework-schedule", ".service"],
[bench_name + "-xhiveframework-web", ".service"],
[bench_name + "-node-socketio", ".service"],
[bench_name + "-redis-cache", ".service"],
[bench_name + "-redis-queue", ".service"],


+ 5
- 5
bench/config/templates/Procfile Прегледај датотеку

@@ -5,7 +5,7 @@ redis_queue: redis-server config/redis_queue.conf
{% endif %}
web: bench serve {% if webserver_port -%} --port {{ webserver_port }} {%- endif %}

socketio: {{ node }} apps/frappe/socketio.js
socketio: {{ node }} apps/xhiveframework/socketio.js
{% if not CI %}
watch: bench watch
{% endif %}
@@ -16,8 +16,8 @@ worker: bench worker 1>> logs/worker.log 2>> logs/worker.error.log
worker_{{ worker_name }}: bench worker --queue {{ worker_name }} 1>> logs/worker.log 2>> logs/worker.error.log
{% endfor %}
{% else %}
workerbeat: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app beat -s scheduler.schedule'
worker: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app worker -n jobs@%h -Ofair --soft-time-limit 360 --time-limit 390'
longjob_worker: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app worker -n longjobs@%h -Ofair --soft-time-limit 1500 --time-limit 1530'
async_worker: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app worker -n async@%h -Ofair --soft-time-limit 1500 --time-limit 1530'
workerbeat: sh -c 'cd sites && exec ../env/bin/python -m xhiveframework.celery_app beat -s scheduler.schedule'
worker: sh -c 'cd sites && exec ../env/bin/python -m xhiveframework.celery_app worker -n jobs@%h -Ofair --soft-time-limit 360 --time-limit 390'
longjob_worker: sh -c 'cd sites && exec ../env/bin/python -m xhiveframework.celery_app worker -n longjobs@%h -Ofair --soft-time-limit 1500 --time-limit 1530'
async_worker: sh -c 'cd sites && exec ../env/bin/python -m xhiveframework.celery_app worker -n async@%h -Ofair --soft-time-limit 1500 --time-limit 1530'
{%- endif %}

+ 3
- 3
bench/config/templates/bench_manager_nginx.conf Прегледај датотеку

@@ -27,7 +27,7 @@ server {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Frappe-Site-Name {{ bench_manager_site_name }};
proxy_set_header X-Xhive-Site-Name {{ bench_manager_site_name }};
proxy_set_header Origin $scheme://$http_host;
proxy_set_header Host {{ bench_manager_site_name }};

@@ -41,13 +41,13 @@ server {
location @webserver {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frappe-Site-Name {{ bench_manager_site_name }};
proxy_set_header X-Xhive-Site-Name {{ bench_manager_site_name }};
proxy_set_header Host {{ bench_manager_site_name }};
proxy_set_header X-Use-X-Accel-Redirect True;
proxy_read_timeout {{ http_timeout or 120 }};
proxy_redirect off;

proxy_pass http://{{ bench_name }}-frappe;
proxy_pass http://{{ bench_name }}-xhiveframework;
}

# error pages


+ 1
- 1
bench/config/templates/frappe_sudoers Прегледај датотеку

@@ -1,4 +1,4 @@
# This file is auto-generated by frappe/bench
# This file is auto-generated by xhiveframework/bench
# To re-generate this file, run "bench setup sudoers"

{% if service %}


+ 4
- 4
bench/config/templates/nginx.conf Прегледај датотеку

@@ -69,7 +69,7 @@ server {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Frappe-Site-Name {{ site_name }};
proxy_set_header X-Xhive-Site-Name {{ site_name }};
proxy_set_header Origin $scheme://$http_host;
proxy_set_header Host $host;

@@ -94,13 +94,13 @@ server {
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frappe-Site-Name {{ site_name }};
proxy_set_header X-Xhive-Site-Name {{ site_name }};
proxy_set_header Host $host;
proxy_set_header X-Use-X-Accel-Redirect True;
proxy_read_timeout {{ http_timeout or 120 }};
proxy_redirect off;

proxy_pass http://{{ bench_name }}-frappe;
proxy_pass http://{{ bench_name }}-xhiveframework;
}

# error pages
@@ -181,7 +181,7 @@ server {

{%- endmacro -%}

upstream {{ bench_name }}-frappe {
upstream {{ bench_name }}-xhiveframework {
server 127.0.0.1:{{ webserver_port or 8000 }} fail_timeout=0;
}



+ 19
- 19
bench/config/templates/supervisor.conf Прегледај датотеку

@@ -2,8 +2,8 @@
; priority=1 --> Lower priorities indicate programs that start first and shut down last
; killasgroup=true --> send kill signal to child processes too

[program:{{ bench_name }}-frappe-web]
command={{ bench_dir }}/env/bin/gunicorn -b 127.0.0.1:{{ webserver_port }} -w {{ gunicorn_workers }} --max-requests {{ gunicorn_max_requests }} --max-requests-jitter {{ gunicorn_max_requests_jitter }} -t {{ http_timeout }} frappe.app:application --preload
[program:{{ bench_name }}-xhiveframework-web]
command={{ bench_dir }}/env/bin/gunicorn -b 127.0.0.1:{{ webserver_port }} -w {{ gunicorn_workers }} --max-requests {{ gunicorn_max_requests }} --max-requests-jitter {{ gunicorn_max_requests_jitter }} -t {{ http_timeout }} xhiveframework.app:application --preload
priority=4
autostart=true
autorestart=true
@@ -13,7 +13,7 @@ user={{ user }}
directory={{ sites_dir }}

{% if use_rq %}
[program:{{ bench_name }}-frappe-schedule]
[program:{{ bench_name }}-xhiveframework-schedule]
command={{ bench_cmd }} schedule
priority=3
autostart=true
@@ -23,7 +23,7 @@ stderr_logfile={{ bench_dir }}/logs/schedule.error.log
user={{ user }}
directory={{ bench_dir }}

[program:{{ bench_name }}-frappe-default-worker]
[program:{{ bench_name }}-xhiveframework-default-worker]
command={{ bench_cmd }} worker --queue default
priority=4
autostart=true
@@ -37,7 +37,7 @@ killasgroup=true
numprocs={{ background_workers }}
process_name=%(program_name)s-%(process_num)d

[program:{{ bench_name }}-frappe-short-worker]
[program:{{ bench_name }}-xhiveframework-short-worker]
command={{ bench_cmd }} worker --queue short
priority=4
autostart=true
@@ -51,7 +51,7 @@ killasgroup=true
numprocs={{ background_workers }}
process_name=%(program_name)s-%(process_num)d

[program:{{ bench_name }}-frappe-long-worker]
[program:{{ bench_name }}-xhiveframework-long-worker]
command={{ bench_cmd }} worker --queue long
priority=4
autostart=true
@@ -66,7 +66,7 @@ numprocs={{ background_workers }}
process_name=%(program_name)s-%(process_num)d

{% for worker_name, worker_details in workers.items() %}
[program:{{ bench_name }}-frappe-{{ worker_name }}-worker]
[program:{{ bench_name }}-xhiveframework-{{ worker_name }}-worker]
command={{ bench_cmd }} worker --queue {{ worker_name }}
priority=4
autostart=true
@@ -82,8 +82,8 @@ process_name=%(program_name)s-%(process_num)d
{% endfor %}

{% else %}
[program:{{ bench_name }}-frappe-workerbeat]
command={{ bench_dir }}/env/bin/python -m frappe.celery_app beat -s beat.schedule
[program:{{ bench_name }}-xhiveframework-workerbeat]
command={{ bench_dir }}/env/bin/python -m xhiveframework.celery_app beat -s beat.schedule
priority=3
autostart=true
autorestart=true
@@ -92,8 +92,8 @@ stderr_logfile={{ bench_dir }}/logs/workerbeat.error.log
user={{ user }}
directory={{ sites_dir }}

[program:{{ bench_name }}-frappe-worker]
command={{ bench_dir }}/env/bin/python -m frappe.celery_app worker -n jobs@%%h -Ofair --soft-time-limit 360 --time-limit 390 --loglevel INFO
[program:{{ bench_name }}-xhiveframework-worker]
command={{ bench_dir }}/env/bin/python -m xhiveframework.celery_app worker -n jobs@%%h -Ofair --soft-time-limit 360 --time-limit 390 --loglevel INFO
priority=4
autostart=true
autorestart=true
@@ -104,8 +104,8 @@ stopwaitsecs=400
directory={{ sites_dir }}
killasgroup=true

[program:{{ bench_name }}-frappe-longjob-worker]
command={{ bench_dir }}/env/bin/python -m frappe.celery_app worker -n longjobs@%%h -Ofair --soft-time-limit 1500 --time-limit 1530 --loglevel INFO
[program:{{ bench_name }}-xhiveframework-longjob-worker]
command={{ bench_dir }}/env/bin/python -m xhiveframework.celery_app worker -n longjobs@%%h -Ofair --soft-time-limit 1500 --time-limit 1530 --loglevel INFO
priority=2
autostart=true
autorestart=true
@@ -116,8 +116,8 @@ stopwaitsecs=1540
directory={{ sites_dir }}
killasgroup=true

[program:{{ bench_name }}-frappe-async-worker]
command={{ bench_dir }}/env/bin/python -m frappe.celery_app worker -n async@%%h -Ofair --soft-time-limit 1500 --time-limit 1530 --loglevel INFO
[program:{{ bench_name }}-xhiveframework-async-worker]
command={{ bench_dir }}/env/bin/python -m xhiveframework.celery_app worker -n async@%%h -Ofair --soft-time-limit 1500 --time-limit 1530 --loglevel INFO
priority=2
autostart=true
autorestart=true
@@ -166,7 +166,7 @@ directory={{ sites_dir }}

{% if node %}
[program:{{ bench_name }}-node-socketio]
command={{ node }} {{ bench_dir }}/apps/frappe/socketio.js
command={{ node }} {{ bench_dir }}/apps/xhiveframework/socketio.js
priority=4
autostart=true
autorestart=true
@@ -177,17 +177,17 @@ directory={{ bench_dir }}
{% endif %}

[group:{{ bench_name }}-web]
programs={{ bench_name }}-frappe-web {%- if node -%} ,{{ bench_name }}-node-socketio {%- endif%}
programs={{ bench_name }}-xhiveframework-web {%- if node -%} ,{{ bench_name }}-node-socketio {%- endif%}

{% if use_rq %}

[group:{{ bench_name }}-workers]
programs={{ bench_name }}-frappe-schedule,{{ bench_name }}-frappe-default-worker,{{ bench_name }}-frappe-short-worker,{{ bench_name }}-frappe-long-worker
programs={{ bench_name }}-xhiveframework-schedule,{{ bench_name }}-xhiveframework-default-worker,{{ bench_name }}-xhiveframework-short-worker,{{ bench_name }}-xhiveframework-long-worker

{% else %}

[group:{{ bench_name }}-workers]
programs={{ bench_name }}-frappe-workerbeat,{{ bench_name }}-frappe-worker,{{ bench_name }}-frappe-longjob-worker,{{ bench_name }}-frappe-async-worker
programs={{ bench_name }}-xhiveframework-workerbeat,{{ bench_name }}-xhiveframework-worker,{{ bench_name }}-xhiveframework-longjob-worker,{{ bench_name }}-xhiveframework-async-worker

{% endif %}



+ 1
- 1
bench/config/templates/systemd/frappe-bench-frappe-default-worker.service Прегледај датотеку

@@ -1,5 +1,5 @@
[Unit]
Description="{{ bench_name }}-frappe-default-worker %I"
Description="{{ bench_name }}-xhiveframework-default-worker %I"
PartOf={{ bench_name }}-workers.target

[Service]


+ 1
- 1
bench/config/templates/systemd/frappe-bench-frappe-long-worker.service Прегледај датотеку

@@ -1,5 +1,5 @@
[Unit]
Description="{{ bench_name }}-frappe-short-worker %I"
Description="{{ bench_name }}-xhiveframework-short-worker %I"
PartOf={{ bench_name }}-workers.target

[Service]


+ 1
- 1
bench/config/templates/systemd/frappe-bench-frappe-schedule.service Прегледај датотеку

@@ -1,5 +1,5 @@
[Unit]
Description="{{ bench_name }}-frappe-schedule"
Description="{{ bench_name }}-xhiveframework-schedule"
PartOf={{ bench_name }}-workers.target

[Service]


+ 1
- 1
bench/config/templates/systemd/frappe-bench-frappe-short-worker.service Прегледај датотеку

@@ -1,5 +1,5 @@
[Unit]
Description="{{ bench_name }}-frappe-short-worker %I"
Description="{{ bench_name }}-xhiveframework-short-worker %I"
PartOf={{ bench_name }}-workers.target

[Service]


+ 2
- 2
bench/config/templates/systemd/frappe-bench-frappe-web.service Прегледај датотеку

@@ -1,12 +1,12 @@
[Unit]
Description="{{ bench_name }}-frappe-web"
Description="{{ bench_name }}-xhiveframework-web"
PartOf={{ bench_name }}-web.target

[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ bench_dir }}/env/bin/gunicorn -b 127.0.0.1:{{ webserver_port }} -w {{ gunicorn_workers }} -t {{ http_timeout }} --max-requests {{ gunicorn_max_requests }} --max-requests-jitter {{ gunicorn_max_requests_jitter }} frappe.app:application --preload
ExecStart={{ bench_dir }}/env/bin/gunicorn -b 127.0.0.1:{{ webserver_port }} -w {{ gunicorn_workers }} -t {{ http_timeout }} --max-requests {{ gunicorn_max_requests }} --max-requests-jitter {{ gunicorn_max_requests_jitter }} xhiveframework.app:application --preload
StandardOutput=file:{{ bench_dir }}/logs/web.log
StandardError=file:{{ bench_dir }}/logs/web.error.log
WorkingDirectory={{ sites_dir }}

+ 2
- 2
bench/config/templates/systemd/frappe-bench-node-socketio.service Прегледај датотеку

@@ -1,5 +1,5 @@
[Unit]
After={{ bench_name }}-frappe-web.service
After={{ bench_name }}-xhiveframework-web.service
Description="{{ bench_name }}-node-socketio"
PartOf={{ bench_name }}-web.target

@@ -7,7 +7,7 @@ PartOf={{ bench_name }}-web.target
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ node }} {{ bench_dir }}/apps/frappe/socketio.js
ExecStart={{ node }} {{ bench_dir }}/apps/xhiveframework/socketio.js
StandardOutput=file:{{ bench_dir }}/logs/node-socketio.log
StandardError=file:{{ bench_dir }}/logs/node-socketio.error.log
WorkingDirectory={{ bench_dir }}

+ 1
- 1
bench/config/templates/systemd/frappe-bench-web.target Прегледај датотеку

@@ -1,6 +1,6 @@
[Unit]
After=network.target
Wants={{ bench_name }}-frappe-web.service {{ bench_name }}-node-socketio.service
Wants={{ bench_name }}-xhiveframework-web.service {{ bench_name }}-node-socketio.service

[Install]
WantedBy=multi-user.target

+ 1
- 1
bench/patches/v5/fix_backup_cronjob.py Прегледај датотеку

@@ -7,7 +7,7 @@ def execute(bench_path):
This patch fixes a cron job that would backup sites every minute per 6 hours
"""

user = get_config(bench_path=bench_path).get("frappe_user")
user = get_config(bench_path=bench_path).get("xhiveframework_user")
user_crontab = CronTab(user=user)

for job in user_crontab.find_comment("bench auto backups set for every 6 hours"):


+ 1
- 1
bench/patches/v5/fix_user_permissions.py Прегледај датотеку

@@ -51,7 +51,7 @@ def is_production_set(bench_path):

def execute(bench_path):
"""This patch checks if bench sudoers is set and regenerate supervisor and sudoers files"""
user = get_config(".").get("frappe_user") or getpass.getuser()
user = get_config(".").get("xhiveframework_user") or getpass.getuser()

if is_sudoers_set():
if is_production_set(bench_path):


+ 4
- 4
bench/patches/v5/update_archived_sites.py Прегледај датотеку

@@ -1,12 +1,12 @@
"""
Deprecate archived_sites folder for consistency. This change is
only for Frappe v14 benches. If not a v14 bench yet, skip this
only for Xhive v14 benches. If not a v14 bench yet, skip this
patch and try again later.

1. Rename folder `./archived_sites` to `./archived/sites`
2. Create a symlink `./archived_sites` => `./archived/sites`

Corresponding changes in frappe/frappe via https://github.com/frappe/frappe/pull/15060
Corresponding changes in xhiveframework/xhiveframework via https://lab.membtech.com/xhiveframework/xhiveframework/pull/15060
"""
import os
from pathlib import Path
@@ -17,9 +17,9 @@ from semantic_version import Version


def execute(bench_path):
frappe_version = Version(get_current_version("frappe"))
xhiveframework_version = Version(get_current_version("xhiveframework"))

if frappe_version.major < 14 or os.name != "posix":
if xhiveframework_version.major < 14 or os.name != "posix":
# Returning False means patch has been skipped
return False



+ 2
- 2
bench/playbooks/README.md Прегледај датотеку

@@ -1,4 +1,4 @@
# Deploying a, developer/production-ready ERPNext website with Ansible
# Deploying a, developer/production-ready XhiveERP website with Ansible

## Supported Platforms
- Debian 8, 9
@@ -6,5 +6,5 @@
- CentOS 7

## Notes for maintainers
- For MariaDB playbooks refer https://github.com/PCextreme/ansible-role-mariadb
- For MariaDB playbooks refer https://github.com/PCextreme/ansible-role-mariadb
- Any changes made in relation to a role should be dont inside the role and not outside it

+ 6
- 6
bench/playbooks/create_user.yml Прегледај датотеку

@@ -6,24 +6,24 @@
tasks:
- name: Create user
user:
name: '{{ frappe_user }}'
name: '{{ xhiveframework_user }}'
generate_ssh_key: yes

- name: Set home folder perms
file:
path: '{{ user_directory }}'
mode: 'o+rx'
owner: '{{ frappe_user }}'
group: '{{ frappe_user }}'
owner: '{{ xhiveframework_user }}'
group: '{{ xhiveframework_user }}'
recurse: yes

- name: Set /tmp/.bench folder perms
file:
path: '{{ repo_path }}'
owner: '{{ frappe_user }}'
group: '{{ frappe_user }}'
owner: '{{ xhiveframework_user }}'
group: '{{ xhiveframework_user }}'
recurse: yes

- name: Change default shell to bash
shell: "chsh {{ frappe_user }} -s $(which bash)"
shell: "chsh {{ xhiveframework_user }} -s $(which bash)"
...

+ 3
- 3
bench/playbooks/macosx.yml Прегледај датотеку

@@ -5,7 +5,7 @@

vars:
bench_repo_path: "/Users/{{ ansible_user_id }}/.bench"
bench_path: "/Users/{{ ansible_user_id }}/frappe-bench"
bench_path: "/Users/{{ ansible_user_id }}/xhiveframework-bench"

tasks:
- name: install prequisites
@@ -31,11 +31,11 @@
- name: Install MySQLdb in global env
pip: name=mysql-python version=1.2.5

# setup frappe-bench
# setup xhiveframework-bench
- include: includes/setup_bench.yml

# setup development environment
- include: includes/setup_dev_env.yml
when: not production

...
...

+ 5
- 5
bench/playbooks/roles/bench/tasks/main.yml Прегледај датотеку

@@ -33,16 +33,16 @@

- name: Fix permissions
become_user: root
command: chown {{ frappe_user }} -R {{ user_directory }}
command: chown {{ xhiveframework_user }} -R {{ user_directory }}

- name: python3 bench init for develop
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }} --python {{ python }}
command: bench init {{ bench_path }} --xhiveframework-path {{ xhiveframework_repo_url }} --xhiveframework-branch {{ xhiveframework_branch }} --python {{ python }}
args:
creates: "{{ bench_path }}"
when: not bench_stat.stat.exists and not production

- name: python3 bench init for production
command: bench init {{ bench_path }} --frappe-path {{ frappe_repo_url }} --frappe-branch {{ frappe_branch }} --python {{ python }}
command: bench init {{ bench_path }} --xhiveframework-path {{ xhiveframework_repo_url }} --xhiveframework-branch {{ xhiveframework_branch }} --python {{ python }}
args:
creates: "{{ bench_path }}"
when: not bench_stat.stat.exists and production
@@ -70,8 +70,8 @@
creates: "{{ bench_path }}/config/redis_socketio.conf"
chdir: "{{ bench_path }}"

# Setup an ERPNext site
- include_tasks: setup_erpnext.yml
# Setup an XhiveERP site
- include_tasks: setup_xhiveerp.yml
when: not run_travis

# Setup Bench for production environment


+ 5
- 5
bench/playbooks/roles/bench/tasks/setup_bench_production.yml Прегледај датотеку

@@ -2,22 +2,22 @@
- name: Setup production
become: yes
become_user: root
command: bench setup production {{ frappe_user }} --yes
command: bench setup production {{ xhiveframework_user }} --yes
args:
chdir: '{{ bench_path }}'

- name: Setup Sudoers
become: yes
become_user: root
command: bench setup sudoers {{ frappe_user }}
command: bench setup sudoers {{ xhiveframework_user }}
args:
chdir: '{{ bench_path }}'

- name: Set correct permissions on bench.log
file:
path: '{{ bench_path }}/logs/bench.log'
owner: '{{ frappe_user }}'
group: '{{ frappe_user }}'
owner: '{{ xhiveframework_user }}'
group: '{{ xhiveframework_user }}'
become: yes
become_user: root

@@ -25,4 +25,4 @@
command: bench restart
args:
chdir: '{{ bench_path }}'
...
...

+ 10
- 10
bench/playbooks/roles/bench/tasks/setup_erpnext.yml Прегледај датотеку

@@ -1,14 +1,14 @@
---
- name: Check if ERPNext App exists
stat: path="{{ bench_path }}/apps/erpnext"
- name: Check if XhiveERP App exists
stat: path="{{ bench_path }}/apps/xhiveerp"
register: app

- name: Get the ERPNext app
command: bench get-app erpnext {{ erpnext_repo_url }} --branch {{ erpnext_branch }}
- name: Get the XhiveERP app
command: bench get-app xhiveerp {{ xhiveerp_repo_url }} --branch {{ xhiveerp_branch }}
args:
creates: "{{ bench_path }}/apps/erpnext"
creates: "{{ bench_path }}/apps/xhiveerp"
chdir: "{{ bench_path }}"
when: not app.stat.exists and not without_erpnext
when: not app.stat.exists and not without_xhiveerp

- name: Check whether the site already exists
stat: path="{{ bench_path }}/sites/{{ site }}"
@@ -21,9 +21,9 @@
chdir: "{{ bench_path }}"
when: not without_site and not site_folder.stat.exists

- name: Install ERPNext to default site
command: "bench --site {{ site }} install-app erpnext"
- name: Install XhiveERP to default site
command: "bench --site {{ site }} install-app xhiveerp"
args:
chdir: "{{ bench_path }}"
when: not without_site and not without_erpnext
...
when: not without_site and not without_xhiveerp
...

+ 3
- 3
bench/playbooks/roles/common/tasks/macos.yml Прегледај датотеку

@@ -5,7 +5,7 @@
become_user: root
vars:
bench_repo_path: "/Users/{{ ansible_user_id }}/.bench"
bench_path: "/Users/{{ ansible_user_id }}/frappe-bench"
bench_path: "/Users/{{ ansible_user_id }}/xhiveframework-bench"
tasks:
# install pre-requisites
- name: install prequisites
@@ -29,11 +29,11 @@
vars:
mysql_conf_tpl: roles/mariadb/files/mariadb_config.cnf

# setup frappe-bench
# setup xhiveframework-bench
- include_tasks: includes/setup_bench.yml

# setup development environment
- include_tasks: includes/setup_dev_env.yml
when: not production

...
...

+ 2
- 2
bench/playbooks/roles/frappe_selinux/files/frappe_selinux.te Прегледај датотеку

@@ -1,4 +1,4 @@
module frappe_selinux 1.0;
module xhiveframework_selinux 1.0;

require {
type user_home_dir_t;
@@ -29,4 +29,4 @@ allow httpd_t user_home_t:file open;
allow httpd_t user_home_t:file read;

#!!!! This avc is allowed in the current policy
allow httpd_t user_home_t:lnk_file read;
allow httpd_t user_home_t:lnk_file read;

+ 7
- 7
bench/playbooks/roles/frappe_selinux/tasks/main.yml Прегледај датотеку

@@ -12,14 +12,14 @@
register: enabled_modules
when: ansible_distribution == 'CentOS'

- name: Copy frappe_selinux policy
copy: src=frappe_selinux.te dest=/root/frappe_selinux.te
register: dest_frappe_selinux_te
- name: Copy xhiveframework_selinux policy
copy: src=xhiveframework_selinux.te dest=/root/xhiveframework_selinux.te
register: dest_xhiveframework_selinux_te
when: ansible_distribution == 'CentOS'

- name: Compile frappe_selinux policy
shell: "make -f /usr/share/selinux/devel/Makefile frappe_selinux.pp && semodule -i frappe_selinux.pp"
- name: Compile xhiveframework_selinux policy
shell: "make -f /usr/share/selinux/devel/Makefile xhiveframework_selinux.pp && semodule -i xhiveframework_selinux.pp"
args:
chdir: /root/
when: "ansible_distribution == 'CentOS' and enabled_modules.stdout.find('frappe_selinux') == -1 or dest_frappe_selinux_te.changed"
...
when: "ansible_distribution == 'CentOS' and enabled_modules.stdout.find('xhiveframework_selinux') == -1 or dest_xhiveframework_selinux_te.changed"
...

+ 1
- 1
bench/playbooks/roles/mariadb/tasks/main.yml Прегледај датотеку

@@ -43,7 +43,7 @@

- name: Add additional conf for MariaDB 10.2 in mariadb.conf.d
blockinfile:
path: /etc/mysql/mariadb.conf.d/erpnext.cnf
path: /etc/mysql/mariadb.conf.d/xhiveerp.cnf
block: |
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid


+ 3
- 3
bench/playbooks/site.yml Прегледај датотеку

@@ -1,5 +1,5 @@
---
# This is the master playbook that deploys the whole Frappe and ERPNext stack
# This is the master playbook that deploys the whole Xhive and XhiveERP stack

- hosts: localhost
become: yes
@@ -12,7 +12,7 @@
- { role: swap, tags: swap, when: production and not container }
- { role: logwatch, tags: logwatch, when: production }
- { role: bash_screen_wall, tags: bash_screen_wall, when: production }
- { role: frappe_selinux, tags: frappe_selinux, when: production }
- { role: xhiveframework_selinux, tags: xhiveframework_selinux, when: production }
- { role: dns_caching, tags: dns_caching, when: production }
- { role: ntpd, tags: ntpd, when: production }
- { role: wkhtmltopdf, tags: wkhtmltopdf }
@@ -43,6 +43,6 @@
bench_repo_path: "{{ user_directory }}/.bench"
bench_path: "{{ user_directory }}/{{ bench_name }}"
roles:
# setup frappe-bench
# setup xhiveframework-bench
- { role: bench, tags: "bench", when: not run_travis and not without_bench_setup }
...

+ 9
- 9
bench/tests/test_base.py Прегледај датотеку

@@ -15,10 +15,10 @@ from bench.bench import Bench

PYTHON_VER = sys.version_info

FRAPPE_BRANCH = "version-13-hotfix"
XHIVEFRAMEWORK_BRANCH = "version-13-hotfix"
if PYTHON_VER.major == 3:
if PYTHON_VER.minor >= 10:
FRAPPE_BRANCH = "develop"
XHIVEFRAMEWORK_BRANCH = "develop"


class TestBenchBase(unittest.TestCase):
@@ -55,7 +55,7 @@ class TestBenchBase(unittest.TestCase):
def assert_folders(self, bench_name):
for folder in paths_in_bench:
self.assert_exists(bench_name, folder)
self.assert_exists(bench_name, "apps", "frappe")
self.assert_exists(bench_name, "apps", "xhiveframework")

def assert_virtual_env(self, bench_name):
bench_path = os.path.abspath(bench_name)
@@ -101,11 +101,11 @@ class TestBenchBase(unittest.TestCase):

def init_bench(self, bench_name, **kwargs):
self.benches.append(bench_name)
frappe_tmp_path = "/tmp/frappe"
xhiveframework_tmp_path = "/tmp/xhiveframework"

if not os.path.exists(frappe_tmp_path):
if not os.path.exists(xhiveframework_tmp_path):
exec_cmd(
f"git clone https://github.com/frappe/frappe -b {FRAPPE_BRANCH} --depth 1 --origin upstream {frappe_tmp_path}"
f"git clone https://lab.membtech.com/xhiveframework/xhiveframework -b {XHIVEFRAMEWORK_BRANCH} --depth 1 --origin upstream {xhiveframework_tmp_path}"
)

kwargs.update(
@@ -113,15 +113,15 @@ class TestBenchBase(unittest.TestCase):
python=sys.executable,
no_procfile=True,
no_backups=True,
frappe_path=frappe_tmp_path,
xhiveframework_path=xhiveframework_tmp_path,
)
)

if not os.path.exists(os.path.join(self.benches_path, bench_name)):
init(bench_name, **kwargs)
exec_cmd(
"git remote set-url upstream https://github.com/frappe/frappe",
cwd=os.path.join(self.benches_path, bench_name, "apps", "frappe"),
"git remote set-url upstream https://lab.membtech.com/xhiveframework/xhiveframework",
cwd=os.path.join(self.benches_path, bench_name, "apps", "xhiveframework"),
)

def file_exists(self, path):


+ 32
- 32
bench/tests/test_init.py Прегледај датотеку

@@ -10,14 +10,14 @@ import git
# imports - module imports
from bench.utils import exec_cmd
from bench.app import App
from bench.tests.test_base import FRAPPE_BRANCH, TestBenchBase
from bench.tests.test_base import XHIVEFRAMEWORK_BRANCH, TestBenchBase
from bench.bench import Bench


# changed from frappe_theme because it wasn't maintained and incompatible,
# chat app & wiki was breaking too. hopefully frappe_docs will be maintained
# for longer since docs.erpnext.com is powered by it ;)
TEST_FRAPPE_APP = "frappe_docs"
# changed from xhiveframework_theme because it wasn't maintained and incompatible,
# chat app & wiki was breaking too. hopefully xhiveframework_docs will be maintained
# for longer since docs.xhiveerp.com is powered by it ;)
TEST_XHIVEFRAMEWORK_APP = "xhiveframework_docs"


class TestBenchInit(TestBenchBase):
@@ -26,16 +26,16 @@ class TestBenchInit(TestBenchBase):

def test_init(self, bench_name="test-bench", **kwargs):
self.init_bench(bench_name, **kwargs)
app = App("file:///tmp/frappe")
app = App("file:///tmp/xhiveframework")
self.assertTupleEqual(
(app.mount_path, app.url, app.repo, app.org),
("/tmp/frappe", "file:///tmp/frappe", "frappe", "frappe"),
("/tmp/xhiveframework", "file:///tmp/xhiveframework", "xhiveframework", "xhiveframework"),
)
self.assert_folders(bench_name)
self.assert_virtual_env(bench_name)
self.assert_config(bench_name)
test_bench = Bench(bench_name)
app = App("frappe", bench=test_bench)
app = App("xhiveframework", bench=test_bench)
self.assertEqual(app.from_apps, True)

def basic(self):
@@ -98,20 +98,20 @@ class TestBenchInit(TestBenchBase):
def test_get_app(self):
self.init_bench("test-bench", skip_assets=True)
bench_path = os.path.join(self.benches_path, "test-bench")
exec_cmd(f"bench get-app {TEST_FRAPPE_APP} --skip-assets", cwd=bench_path)
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", TEST_FRAPPE_APP)))
app_installed_in_env = TEST_FRAPPE_APP in subprocess.check_output(
exec_cmd(f"bench get-app {TEST_XHIVEFRAMEWORK_APP} --skip-assets", cwd=bench_path)
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", TEST_XHIVEFRAMEWORK_APP)))
app_installed_in_env = TEST_XHIVEFRAMEWORK_APP in subprocess.check_output(
["bench", "pip", "freeze"], cwd=bench_path
).decode("utf8")
self.assertTrue(app_installed_in_env)

@unittest.skipIf(FRAPPE_BRANCH != "develop", "only for develop branch")
@unittest.skipIf(XHIVEFRAMEWORK_BRANCH != "develop", "only for develop branch")
def test_get_app_resolve_deps(self):
FRAPPE_APP = "healthcare"
XHIVEFRAMEWORK_APP = "healthcare"
self.init_bench("test-bench", skip_assets=True)
bench_path = os.path.join(self.benches_path, "test-bench")
exec_cmd(f"bench get-app {FRAPPE_APP} --resolve-deps --skip-assets", cwd=bench_path)
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", FRAPPE_APP)))
exec_cmd(f"bench get-app {XHIVEFRAMEWORK_APP} --resolve-deps --skip-assets", cwd=bench_path)
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", XHIVEFRAMEWORK_APP)))

states_path = os.path.join(bench_path, "sites", "apps.json")
self.assertTrue(os.path.exists(states_path))
@@ -119,7 +119,7 @@ class TestBenchInit(TestBenchBase):
with open(states_path) as f:
states = json.load(f)

self.assertTrue(FRAPPE_APP in states)
self.assertTrue(XHIVEFRAMEWORK_APP in states)

def test_install_app(self):
bench_name = "test-bench"
@@ -128,13 +128,13 @@ class TestBenchInit(TestBenchBase):

self.init_bench(bench_name, skip_assets=True)
exec_cmd(
f"bench get-app {TEST_FRAPPE_APP} --branch master --skip-assets", cwd=bench_path
f"bench get-app {TEST_XHIVEFRAMEWORK_APP} --branch master --skip-assets", cwd=bench_path
)

self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", TEST_FRAPPE_APP)))
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", TEST_XHIVEFRAMEWORK_APP)))

# check if app is installed
app_installed_in_env = TEST_FRAPPE_APP in subprocess.check_output(
app_installed_in_env = TEST_XHIVEFRAMEWORK_APP in subprocess.check_output(
["bench", "pip", "freeze"], cwd=bench_path
).decode("utf8")
self.assertTrue(app_installed_in_env)
@@ -142,7 +142,7 @@ class TestBenchInit(TestBenchBase):
# create and install app on site
self.new_site(site_name, bench_name)
installed_app = not exec_cmd(
f"bench --site {site_name} install-app {TEST_FRAPPE_APP}",
f"bench --site {site_name} install-app {TEST_XHIVEFRAMEWORK_APP}",
cwd=bench_path,
_raise=False,
)
@@ -151,39 +151,39 @@ class TestBenchInit(TestBenchBase):
app_installed_on_site = subprocess.check_output(
["bench", "--site", site_name, "list-apps"], cwd=bench_path
).decode("utf8")
self.assertTrue(TEST_FRAPPE_APP in app_installed_on_site)
self.assertTrue(TEST_XHIVEFRAMEWORK_APP in app_installed_on_site)

def test_remove_app(self):
self.init_bench("test-bench", skip_assets=True)
bench_path = os.path.join(self.benches_path, "test-bench")

exec_cmd(
f"bench get-app {TEST_FRAPPE_APP} --branch master --overwrite --skip-assets",
f"bench get-app {TEST_XHIVEFRAMEWORK_APP} --branch master --overwrite --skip-assets",
cwd=bench_path,
)
exec_cmd(f"bench remove-app {TEST_FRAPPE_APP}", cwd=bench_path)
exec_cmd(f"bench remove-app {TEST_XHIVEFRAMEWORK_APP}", cwd=bench_path)

with open(os.path.join(bench_path, "sites", "apps.txt")) as f:
self.assertFalse(TEST_FRAPPE_APP in f.read())
self.assertFalse(TEST_XHIVEFRAMEWORK_APP in f.read())
self.assertFalse(
TEST_FRAPPE_APP
TEST_XHIVEFRAMEWORK_APP
in subprocess.check_output(["bench", "pip", "freeze"], cwd=bench_path).decode("utf8")
)
self.assertFalse(os.path.exists(os.path.join(bench_path, "apps", TEST_FRAPPE_APP)))
self.assertFalse(os.path.exists(os.path.join(bench_path, "apps", TEST_XHIVEFRAMEWORK_APP)))

def test_switch_to_branch(self):
self.init_bench("test-bench", skip_assets=True)
bench_path = os.path.join(self.benches_path, "test-bench")
app_path = os.path.join(bench_path, "apps", "frappe")
app_path = os.path.join(bench_path, "apps", "xhiveframework")

# * chore: change to 14 when avalible
prevoius_branch = "version-13"
if FRAPPE_BRANCH != "develop":
if XHIVEFRAMEWORK_BRANCH != "develop":
# assuming we follow `version-#`
prevoius_branch = f"version-{int(FRAPPE_BRANCH.split('-')[1]) - 1}"
prevoius_branch = f"version-{int(XHIVEFRAMEWORK_BRANCH.split('-')[1]) - 1}"

successful_switch = not exec_cmd(
f"bench switch-to-branch {prevoius_branch} frappe --upgrade",
f"bench switch-to-branch {prevoius_branch} xhiveframework --upgrade",
cwd=bench_path,
_raise=False,
)
@@ -192,13 +192,13 @@ class TestBenchInit(TestBenchBase):
self.assertEqual(prevoius_branch, app_branch_after_switch)

successful_switch = not exec_cmd(
f"bench switch-to-branch {FRAPPE_BRANCH} frappe --upgrade",
f"bench switch-to-branch {XHIVEFRAMEWORK_BRANCH} xhiveframework --upgrade",
cwd=bench_path,
_raise=False,
)
if successful_switch:
app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch)
self.assertEqual(FRAPPE_BRANCH, app_branch_after_second_switch)
self.assertEqual(XHIVEFRAMEWORK_BRANCH, app_branch_after_second_switch)


if __name__ == "__main__":


+ 20
- 20
bench/tests/test_setup_production.py Прегледај датотеку

@@ -56,7 +56,7 @@ class TestSetupProduction(TestBenchBase):
f = f.read()

for key in (
f"upstream {bench_name}-frappe",
f"upstream {bench_name}-xhiveframework",
f"upstream {bench_name}-socketio-server",
):
self.assertTrue(key in f)
@@ -68,7 +68,7 @@ class TestSetupProduction(TestBenchBase):
)

def assert_sudoers(self, user):
sudoers_file = "/etc/sudoers.d/frappe"
sudoers_file = "/etc/sudoers.d/xhiveframework"
service = which("service")
nginx = which("nginx")

@@ -100,7 +100,7 @@ class TestSetupProduction(TestBenchBase):
f = f.read()

tests = [
f"program:{bench_name}-frappe-web",
f"program:{bench_name}-xhiveframework-web",
f"program:{bench_name}-redis-cache",
f"program:{bench_name}-redis-queue",
f"program:{bench_name}-redis-socketio",
@@ -115,20 +115,20 @@ class TestSetupProduction(TestBenchBase):
if use_rq:
tests.extend(
[
f"program:{bench_name}-frappe-schedule",
f"program:{bench_name}-frappe-default-worker",
f"program:{bench_name}-frappe-short-worker",
f"program:{bench_name}-frappe-long-worker",
f"program:{bench_name}-xhiveframework-schedule",
f"program:{bench_name}-xhiveframework-default-worker",
f"program:{bench_name}-xhiveframework-short-worker",
f"program:{bench_name}-xhiveframework-long-worker",
]
)

else:
tests.extend(
[
f"program:{bench_name}-frappe-workerbeat",
f"program:{bench_name}-frappe-worker",
f"program:{bench_name}-frappe-longjob-worker",
f"program:{bench_name}-frappe-async-worker",
f"program:{bench_name}-xhiveframework-workerbeat",
f"program:{bench_name}-xhiveframework-worker",
f"program:{bench_name}-xhiveframework-longjob-worker",
f"program:{bench_name}-xhiveframework-async-worker",
]
)

@@ -144,7 +144,7 @@ class TestSetupProduction(TestBenchBase):
out = get_cmd_output("supervisorctl status")

tests = [
r"{bench_name}-web:{bench_name}-frappe-web[\s]+RUNNING",
r"{bench_name}-web:{bench_name}-xhiveframework-web[\s]+RUNNING",
# Have commented for the time being. Needs to be uncommented later on. Bench is failing on travis because of this.
# It works on one bench and fails on another.giving FATAL or BACKOFF (Exited too quickly (process log may have details))
# "{bench_name}-web:{bench_name}-node-socketio[\s]+RUNNING",
@@ -156,20 +156,20 @@ class TestSetupProduction(TestBenchBase):
if use_rq:
tests.extend(
[
r"{bench_name}-workers:{bench_name}-frappe-schedule[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-frappe-default-worker-0[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-frappe-short-worker-0[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-frappe-long-worker-0[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-xhiveframework-schedule[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-xhiveframework-default-worker-0[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-xhiveframework-short-worker-0[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-xhiveframework-long-worker-0[\s]+RUNNING",
]
)

else:
tests.extend(
[
r"{bench_name}-workers:{bench_name}-frappe-workerbeat[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-frappe-worker[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-frappe-longjob-worker[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-frappe-async-worker[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-xhiveframework-workerbeat[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-xhiveframework-worker[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-xhiveframework-longjob-worker[\s]+RUNNING",
r"{bench_name}-workers:{bench_name}-xhiveframework-async-worker[\s]+RUNNING",
]
)



+ 27
- 27
bench/tests/test_utils.py Прегледај датотеку

@@ -6,12 +6,12 @@ import unittest
from bench.app import App
from bench.bench import Bench
from bench.exceptions import InvalidRemoteException
from bench.utils import is_valid_frappe_branch
from bench.utils import is_valid_xhiveframework_branch


class TestUtils(unittest.TestCase):
def test_app_utils(self):
git_url = "https://github.com/frappe/frappe"
git_url = "https://lab.membtech.com/xhiveframework/xhiveframework"
branch = "develop"
app = App(name=git_url, branch=branch, bench=Bench("."))
self.assertTrue(
@@ -22,26 +22,26 @@ class TestUtils(unittest.TestCase):
app.tag == branch,
app.is_url is True,
app.on_disk is False,
app.org == "frappe",
app.org == "xhiveframework",
app.url == git_url,
]
)
)

def test_is_valid_frappe_branch(self):
def test_is_valid_xhiveframework_branch(self):
with self.assertRaises(InvalidRemoteException):
is_valid_frappe_branch(
"https://github.com/frappe/frappe.git", frappe_branch="random-branch"
is_valid_xhiveframework_branch(
"https://lab.membtech.com/xhiveframework/xhiveframework.git", xhiveframework_branch="random-branch"
)
is_valid_frappe_branch(
"https://github.com/random/random.git", frappe_branch="random-branch"
is_valid_xhiveframework_branch(
"https://github.com/random/random.git", xhiveframework_branch="random-branch"
)

is_valid_frappe_branch(
"https://github.com/frappe/frappe.git", frappe_branch="develop"
is_valid_xhiveframework_branch(
"https://lab.membtech.com/xhiveframework/xhiveframework.git", xhiveframework_branch="develop"
)
is_valid_frappe_branch(
"https://github.com/frappe/frappe.git", frappe_branch="v13.29.0"
is_valid_xhiveframework_branch(
"https://lab.membtech.com/xhiveframework/xhiveframework.git", xhiveframework_branch="v13.29.0"
)

def test_app_states(self):
@@ -56,7 +56,7 @@ class TestUtils(unittest.TestCase):
self.assertTrue(hasattr(fake_bench.apps, "states"))

fake_bench.apps.states = {
"frappe": {
"xhiveframework": {
"resolution": {"branch": "develop", "commit_hash": "234rwefd"},
"version": "14.0.0-dev",
}
@@ -65,40 +65,40 @@ class TestUtils(unittest.TestCase):

self.assertEqual(fake_bench.apps.states, {})

frappe_path = os.path.join(bench_dir, "apps", "frappe")
xhiveframework_path = os.path.join(bench_dir, "apps", "xhiveframework")

os.makedirs(os.path.join(frappe_path, "frappe"))
os.makedirs(os.path.join(xhiveframework_path, "xhiveframework"))

subprocess.run(["git", "init"], cwd=frappe_path, capture_output=True, check=True)
subprocess.run(["git", "init"], cwd=xhiveframework_path, capture_output=True, check=True)

with open(os.path.join(frappe_path, "frappe", "__init__.py"), "w+") as f:
with open(os.path.join(xhiveframework_path, "xhiveframework", "__init__.py"), "w+") as f:
f.write("__version__ = '11.0'")

subprocess.run(["git", "add", "."], cwd=frappe_path, capture_output=True, check=True)
subprocess.run(["git", "add", "."], cwd=xhiveframework_path, capture_output=True, check=True)
subprocess.run(
["git", "config", "user.email", "bench-test_app_states@gha.com"],
cwd=frappe_path,
cwd=xhiveframework_path,
capture_output=True,
check=True,
)
subprocess.run(
["git", "config", "user.name", "App States Test"],
cwd=frappe_path,
cwd=xhiveframework_path,
capture_output=True,
check=True,
)
subprocess.run(
["git", "commit", "-m", "temp"], cwd=frappe_path, capture_output=True, check=True
["git", "commit", "-m", "temp"], cwd=xhiveframework_path, capture_output=True, check=True
)

fake_bench.apps.update_apps_states(app_name="frappe")
fake_bench.apps.update_apps_states(app_name="xhiveframework")

self.assertIn("frappe", fake_bench.apps.states)
self.assertIn("version", fake_bench.apps.states["frappe"])
self.assertEqual("11.0", fake_bench.apps.states["frappe"]["version"])
self.assertIn("xhiveframework", fake_bench.apps.states)
self.assertIn("version", fake_bench.apps.states["xhiveframework"])
self.assertEqual("11.0", fake_bench.apps.states["xhiveframework"]["version"])

shutil.rmtree(bench_dir)

def test_ssh_ports(self):
app = App("git@github.com:22:frappe/frappe")
self.assertEqual((app.use_ssh, app.org, app.repo), (True, "frappe", "frappe"))
app = App("git@github.com:22:xhiveframework/xhiveframework")
self.assertEqual((app.use_ssh, app.org, app.repo), (True, "xhiveframework", "xhiveframework"))

+ 31
- 31
bench/utils/__init__.py Прегледај датотеку

@@ -24,7 +24,7 @@ from bench.exceptions import (
logger = logging.getLogger(PROJECT_NAME)
paths_in_app = ("hooks.py", "modules.txt", "patches.txt")
paths_in_bench = ("apps", "sites", "config", "logs", "config/pids")
sudoers_file = "/etc/sudoers.d/frappe"
sudoers_file = "/etc/sudoers.d/xhiveframework"
UNSET_ARG = object()


@@ -38,29 +38,29 @@ def is_bench_directory(directory=os.path.curdir):
return is_bench


def is_frappe_app(directory: str) -> bool:
is_frappe_app = True
def is_xhiveframework_app(directory: str) -> bool:
is_xhiveframework_app = True

for folder in paths_in_app:
if not is_frappe_app:
if not is_xhiveframework_app:
break

path = glob(os.path.join(directory, "**", folder))
is_frappe_app = is_frappe_app and path
is_xhiveframework_app = is_xhiveframework_app and path

return bool(is_frappe_app)
return bool(is_xhiveframework_app)


@lru_cache(maxsize=None)
def is_valid_frappe_branch(frappe_path: str, frappe_branch: str):
def is_valid_xhiveframework_branch(xhiveframework_path: str, xhiveframework_branch: str):
"""Check if a branch exists in a repo. Throws InvalidRemoteException if branch is not found

Uses native git command to check for branches on a remote.

:param frappe_path: git url
:type frappe_path: str
:param frappe_branch: branch to check
:type frappe_branch: str
:param xhiveframework_path: git url
:type xhiveframework_path: str
:param xhiveframework_branch: branch to check
:type xhiveframework_branch: str
:raises InvalidRemoteException: branch for this repo doesn't exist
"""
from git.cmd import Git
@@ -68,15 +68,15 @@ def is_valid_frappe_branch(frappe_path: str, frappe_branch: str):

g = Git()

if frappe_branch:
if xhiveframework_branch:
try:
res = g.ls_remote("--heads", "--tags", frappe_path, frappe_branch)
res = g.ls_remote("--heads", "--tags", xhiveframework_path, xhiveframework_branch)
if not res:
raise InvalidRemoteException(
f"Invalid branch or tag: {frappe_branch} for the remote {frappe_path}"
f"Invalid branch or tag: {xhiveframework_branch} for the remote {xhiveframework_path}"
)
except GitCommandError as e:
raise InvalidRemoteException(f"Invalid frappe path: {frappe_path}") from e
raise InvalidRemoteException(f"Invalid xhiveframework path: {xhiveframework_path}") from e


def log(message, level=0, no_log=False, stderr=False):
@@ -113,7 +113,7 @@ def check_latest_version():
from semantic_version import Version

try:
pypi_request = requests.get("https://pypi.org/pypi/frappe-bench/json")
pypi_request = requests.get("https://pypi.org/pypi/xhiveframework-bench/json")
except Exception:
# Exceptions thrown are defined in requests.exceptions
# ignore checking on all Exceptions
@@ -229,7 +229,7 @@ def is_root():
return os.getuid() == 0


def run_frappe_cmd(*args, **kwargs):
def run_xhiveframework_cmd(*args, **kwargs):
from bench.cli import from_command_line
from bench.utils.bench import get_env_cmd

@@ -244,7 +244,7 @@ def run_frappe_cmd(*args, **kwargs):
stderr = stdout = None

p = subprocess.Popen(
(f, "-m", "frappe.utils.bench_helper", "frappe") + args,
(f, "-m", "xhiveframework.utils.bench_helper", "xhiveframework") + args,
cwd=sites_dir,
stdout=stdout,
stderr=stderr,
@@ -383,8 +383,8 @@ def find_parent_bench(path: str) -> str:
return find_parent_bench(parent_dir)


def get_env_frappe_commands(bench_path=".") -> List:
"""Caches all available commands (even custom apps) via Frappe
def get_env_xhiveframework_commands(bench_path=".") -> List:
"""Caches all available commands (even custom apps) via Xhive
Default caching behaviour: generated the first time any command (for a specific bench directory)
"""
from bench.utils.bench import get_env_cmd
@@ -395,7 +395,7 @@ def get_env_frappe_commands(bench_path=".") -> List:
try:
return json.loads(
get_cmd_output(
f"{python} -m frappe.utils.bench_helper get-frappe-commands", cwd=sites_path
f"{python} -m xhiveframework.utils.bench_helper get-xhiveframework-commands", cwd=sites_path
)
)

@@ -411,14 +411,14 @@ def find_org(org_repo):

org_repo = org_repo[0]

for org in ["frappe", "erpnext"]:
for org in ["xhiveframework", "xhiveerp"]:
res = requests.head(f"https://api.github.com/repos/{org}/{org_repo}")
if res.status_code in (400, 403):
res = requests.head(f"https://github.com/{org}/{org_repo}")
if res.ok:
return org, org_repo

raise InvalidRemoteException(f"{org_repo} not found in frappe or erpnext")
raise InvalidRemoteException(f"{org_repo} not found in xhiveframework or xhiveerp")


def fetch_details_from_tag(_tag: str) -> Tuple[str, str, str]:
@@ -497,10 +497,10 @@ def get_traceback() -> str:
class _dict(dict):
"""dict like object that exposes keys as attributes"""

# bench port of frappe._dict
# bench port of xhiveframework._dict
def __getattr__(self, key):
ret = self.get(key)
# "__deepcopy__" exception added to fix frappe#14833 via DFP
# "__deepcopy__" exception added to fix xhiveframework#14833 via DFP
if not ret and key.startswith("__") and key != "__deepcopy__":
raise AttributeError()
return ret
@@ -526,15 +526,15 @@ class _dict(dict):
def get_cmd_from_sysargv():
"""Identify and segregate tokens to options and command

For Command: `bench --profile --site frappeframework.com migrate --no-backup`
sys.argv: ["/home/frappe/.local/bin/bench", "--profile", "--site", "frappeframework.com", "migrate", "--no-backup"]
For Command: `bench --profile --site xhiveframework.com migrate --no-backup`
sys.argv: ["/home/xhiveframework/.local/bin/bench", "--profile", "--site", "xhiveframework.com", "migrate", "--no-backup"]
Actual command run: migrate

"""
# context is passed as options to frappe's bench_helper
# context is passed as options to xhiveframework's bench_helper
from bench.bench import Bench

frappe_context = _dict(params={"--site"}, flags={"--verbose", "--profile", "--force"})
xhiveframework_context = _dict(params={"--site"}, flags={"--verbose", "--profile", "--force"})
cmd_from_ctx = None
sys_argv = sys.argv[1:]
skip_next = False
@@ -544,10 +544,10 @@ def get_cmd_from_sysargv():
skip_next = False
continue

if arg in frappe_context.flags:
if arg in xhiveframework_context.flags:
continue

elif arg in frappe_context.params:
elif arg in xhiveframework_context.params:
skip_next = True
continue



+ 3
- 3
bench/utils/app.py Прегледај датотеку

@@ -17,7 +17,7 @@ from bench.exceptions import (
from bench.app import get_repo_dir


def is_version_upgrade(app="frappe", bench_path=".", branch=None):
def is_version_upgrade(app="xhiveframework", bench_path=".", branch=None):
upstream_version = get_upstream_version(app=app, branch=branch, bench_path=bench_path)

if not upstream_version:
@@ -161,9 +161,9 @@ def get_upstream_version(app, branch=None, bench_path="."):
return get_version_from_string(contents)


def get_current_frappe_version(bench_path="."):
def get_current_xhiveframework_version(bench_path="."):
try:
return get_major_version(get_current_version("frappe", bench_path=bench_path))
return get_major_version(get_current_version("xhiveframework", bench_path=bench_path))
except OSError:
return 0



+ 13
- 13
bench/utils/bench.py Прегледај датотеку

@@ -53,9 +53,9 @@ def update_node_packages(bench_path=".", apps=None):

from bench.utils.app import get_develop_version

v = LooseVersion(get_develop_version("frappe", bench_path=bench_path))
v = LooseVersion(get_develop_version("xhiveframework", bench_path=bench_path))

# After rollup was merged, frappe_version = 10.1
# After rollup was merged, xhiveframework_version = 10.1
# if develop_verion is 11 and up, only then install yarn
if v < LooseVersion("11.x.x-develop"):
update_npm_packages(bench_path, apps=apps)
@@ -225,10 +225,10 @@ def migrate_env(python, backup=False):
logger.log(f"Setting up a New Virtual {python} Environment")
exec_cmd(f"{python} -m venv {pvenv}")

# Install frappe first
_install_app("frappe")
# Install xhiveframework first
_install_app("xhiveframework")
for app in bench.apps:
if str(app) != "frappe":
if str(app) != "xhiveframework":
_install_app(app)

logger.log(f"Migration Successful to {python}")
@@ -316,7 +316,7 @@ def restart_supervisor_processes(bench_path=".", web_workers=False, _raise=False

# backward compatibility
else:
group = "frappe:"
group = "xhiveframework:"

failure = bench.run(f"{sudo}supervisorctl restart {group}", _raise=_raise)
if failure:
@@ -357,13 +357,13 @@ def handle_version_upgrade(version_upgrade, bench_path, force, reset, conf):
if version_upgrade[0]:
if force:
log(
"""Force flag has been used for a major version change in Frappe and it's apps.
"""Force flag has been used for a major version change in Xhive and it's apps.
This will take significant time to migrate and might break custom apps.""",
level=3,
)
else:
print(
f"""This update will cause a major version change in Frappe/ERPNext from {version_upgrade[1]} to {version_upgrade[2]}.
f"""This update will cause a major version change in Xhive/XhiveERP from {version_upgrade[1]} to {version_upgrade[2]}.
This would take significant time to migrate and might break custom apps."""
)
click.confirm("Do you want to continue?", abort=True)
@@ -469,8 +469,8 @@ def update(
update_config(conf, bench_path=bench_path)

print(
"_" * 80 + "\nBench: Deployment tool for Frappe and Frappe Applications"
" (https://frappe.io/bench).\nOpen source depends on your contributions, so do"
"_" * 80 + "\nBench: Deployment tool for Xhive and Xhive Applications"
" (https://xhive.io/bench).\nOpen source depends on your contributions, so do"
" give back by submitting bug reports, patches and fixes and be a part of the"
" community :)"
)
@@ -524,7 +524,7 @@ def remove_backups_crontab(bench_path="."):
logger.log("removing backup cronjob")

bench_dir = os.path.abspath(bench_path)
user = Bench(bench_dir).conf.get("frappe_user")
user = Bench(bench_dir).conf.get("xhiveframework_user")
logfile = os.path.join(bench_dir, "logs", "backup.log")
system_crontab = CronTab(user=user)
backup_command = f"cd {bench_dir} && {sys.argv[0]} --verbose --site all backup"
@@ -615,7 +615,7 @@ def validate_branch():
apps = Bench(".").apps

installed_apps = set(apps)
check_apps = {"frappe", "erpnext"}
check_apps = {"xhiveframework", "xhiveerp"}
intersection_apps = installed_apps.intersection(check_apps)

for app in intersection_apps:
@@ -625,7 +625,7 @@ def validate_branch():
print(
"""'master' branch is renamed to 'version-11' since 'version-12' release.
As of January 2020, the following branches are
version Frappe ERPNext
version Xhive XhiveERP
11 version-11 version-11
12 version-12 version-12
13 version-13 version-13


+ 22
- 22
bench/utils/system.py Прегледај датотеку

@@ -11,10 +11,10 @@ from bench.utils import (
exec_cmd,
get_process_manager,
log,
run_frappe_cmd,
run_xhiveframework_cmd,
sudoers_file,
which,
is_valid_frappe_branch,
is_valid_xhiveframework_branch,
)
from bench.utils.bench import build_assets, clone_apps_from
from bench.utils.render import job
@@ -26,8 +26,8 @@ def init(
apps_path=None,
no_procfile=False,
no_backups=False,
frappe_path=None,
frappe_branch=None,
xhiveframework_path=None,
xhiveframework_branch=None,
verbose=False,
clone_from=None,
skip_redis_config_generation=False,
@@ -43,7 +43,7 @@ def init(
* setup env for the bench
* setup config (dir/pids/redis/procfile) for the bench
* setup patches.txt for bench
* clone & install frappe
* clone & install xhiveframework
* install python & node dependencies
* build assets
* setup backups crontab
@@ -74,11 +74,11 @@ def init(

# remote apps
else:
frappe_path = frappe_path or "https://github.com/frappe/frappe.git"
is_valid_frappe_branch(frappe_path=frappe_path, frappe_branch=frappe_branch)
xhiveframework_path = xhiveframework_path or "https://lab.membtech.com/xhiveframework/xhiveframework.git"
is_valid_xhiveframework_branch(xhiveframework_path=xhiveframework_path, xhiveframework_branch=xhiveframework_branch)
get_app(
frappe_path,
branch=frappe_branch,
xhiveframework_path,
branch=xhiveframework_branch,
bench_path=path,
skip_assets=True,
verbose=verbose,
@@ -93,7 +93,7 @@ def init(
if install_app:
get_app(
install_app,
branch=frappe_branch,
branch=xhiveframework_branch,
bench_path=path,
skip_assets=True,
verbose=verbose,
@@ -120,8 +120,8 @@ def setup_sudoers(user):
if set_permissions:
os.chmod("/etc/sudoers", 0o440)

template = bench.config.env().get_template("frappe_sudoers")
frappe_sudoers = template.render(
template = bench.config.env().get_template("xhiveframework_sudoers")
xhiveframework_sudoers = template.render(
**{
"user": user,
"service": which("service"),
@@ -132,7 +132,7 @@ def setup_sudoers(user):
)

with open(sudoers_file, "w") as f:
f.write(frappe_sudoers)
f.write(xhiveframework_sudoers)

os.chmod(sudoers_file, 0o440)
log(f"Sudoers was set up for user {user}", level=1)
@@ -161,11 +161,11 @@ def start(no_dev=False, concurrency=None, procfile=None, no_prefix=False, procma


def migrate_site(site, bench_path="."):
run_frappe_cmd("--site", site, "migrate", bench_path=bench_path)
run_xhiveframework_cmd("--site", site, "migrate", bench_path=bench_path)


def backup_site(site, bench_path="."):
run_frappe_cmd("--site", site, "backup", bench_path=bench_path)
run_xhiveframework_cmd("--site", site, "backup", bench_path=bench_path)


def backup_all_sites(bench_path="."):
@@ -175,21 +175,21 @@ def backup_all_sites(bench_path="."):
backup_site(site, bench_path=bench_path)


def fix_prod_setup_perms(bench_path=".", frappe_user=None):
def fix_prod_setup_perms(bench_path=".", xhiveframework_user=None):
from glob import glob
from bench.bench import Bench

frappe_user = frappe_user or Bench(bench_path).conf.get("frappe_user")
xhiveframework_user = xhiveframework_user or Bench(bench_path).conf.get("xhiveframework_user")

if not frappe_user:
print("frappe user not set")
if not xhiveframework_user:
print("xhiveframework user not set")
sys.exit(1)

globs = ["logs/*", "config/*"]
for glob_name in globs:
for path in glob(glob_name):
uid = pwd.getpwnam(frappe_user).pw_uid
gid = grp.getgrnam(frappe_user).gr_gid
uid = pwd.getpwnam(xhiveframework_user).pw_uid
gid = grp.getgrnam(xhiveframework_user).gr_gid
os.chown(path, uid, gid)


@@ -199,7 +199,7 @@ def setup_fonts():
if os.path.exists("/etc/fonts_backup"):
return

exec_cmd("git clone https://github.com/frappe/fonts.git", cwd="/tmp")
exec_cmd("git clone https://github.com/xhiveframework/fonts.git", cwd="/tmp")
os.rename("/etc/fonts", "/etc/fonts_backup")
os.rename("/usr/share/fonts", "/usr/share/fonts_backup")
os.rename(os.path.join(fonts_path, "etc_fonts"), "/etc/fonts")


+ 4
- 4
bench/utils/translation.py Прегледај датотеку

@@ -19,7 +19,7 @@ def download_translations_p():
pool = multiprocessing.Pool(multiprocessing.cpu_count())

langs = get_langs()
apps = ("frappe", "erpnext")
apps = ("xhiveframework", "xhiveerp")
args = list(itertools.product(apps, langs))

pool.map(update_translations_p, args)
@@ -27,13 +27,13 @@ def download_translations_p():

def download_translations():
langs = get_langs()
apps = ("frappe", "erpnext")
apps = ("xhiveframework", "xhiveerp")
for app, lang in itertools.product(apps, langs):
update_translations(app, lang)


def get_langs():
lang_file = "apps/frappe/frappe/geo/languages.json"
lang_file = "apps/xhiveframework/xhiveframework/geo/languages.json"
with open(lang_file) as f:
langs = json.loads(f.read())
return [d["code"] for d in langs]
@@ -44,7 +44,7 @@ def update_translations(app, lang):

translations_dir = os.path.join("apps", app, app, "translations")
csv_file = os.path.join(translations_dir, f"{lang}.csv")
url = f"https://translate.erpnext.com/files/{app}-{lang}.csv"
url = f"https://translate.xhiveerp.com/files/{app}-{lang}.csv"
r = requests.get(url, stream=True)
r.raise_for_status()



+ 5
- 5
completion.sh Прегледај датотеку

@@ -4,16 +4,16 @@ _bench_completion() {
COMP_CWORD=$COMP_CWORD \
_BENCH_COMPLETE=complete $1 ) )
if [ -d "sites" ]; then
# Also add frappe commands if present
# Also add xhiveframework commands if present

# bench_helper.py expects to be executed from "sites" directory
cd sites

# All frappe commands are subcommands under "bench frappe"
# Frappe is only installed in virtualenv "env" so use appropriate python executable
COMPREPLY+=( $( COMP_WORDS="bench frappe "${COMP_WORDS[@]:1} \
# All xhiveframework commands are subcommands under "bench xhiveframework"
# Xhive is only installed in virtualenv "env" so use appropriate python executable
COMPREPLY+=( $( COMP_WORDS="bench xhiveframework "${COMP_WORDS[@]:1} \
COMP_CWORD=$(($COMP_CWORD+1)) \
_BENCH_COMPLETE=complete ../env/bin/python ../apps/frappe/frappe/utils/bench_helper.py ) )
_BENCH_COMPLETE=complete ../env/bin/python ../apps/xhiveframework/xhiveframework/utils/bench_helper.py ) )

# If the word before the current cursor position in command typed so far is "--site" then only list sites
if [ ${COMP_WORDS[COMP_CWORD-1]} == "--site" ]; then


+ 6
- 6
docs/bench_custom_cmd.md Прегледај датотеку

@@ -1,18 +1,18 @@
## How are Frappe Framework commands available via bench?
## How are Xhive Framework commands available via bench?

bench utilizes `frappe.utils.bench_manager` to get the framework's as well as those of any custom commands written in application installed in the Frappe environment. Currently, with *version 12* there are commands related to the scheduler, sites, translations and other utils in Frappe inherited by bench.
bench utilizes `xhiveframework.utils.bench_manager` to get the framework's as well as those of any custom commands written in application installed in the Xhive environment. Currently, with *version 12* there are commands related to the scheduler, sites, translations and other utils in Xhive inherited by bench.


## Can I add CLI commands in my custom app and call them via bench?

Along with the framework commands, Frappe's `bench_manager` module also searches for any commands in your custom applications. Thereby, bench communicates with the respective bench's Frappe which in turn checks for available commands in all of the applications.
Along with the framework commands, Xhive's `bench_manager` module also searches for any commands in your custom applications. Thereby, bench communicates with the respective bench's Xhive which in turn checks for available commands in all of the applications.

To make your custom command available to bench, just create a `commands` module under your parent module and write the command with a click wrapper and a variable commands which contains a list of click functions, which are your own commands. The directory structure may be visualized as:

```
frappe-bench
xhiveframework-bench
|──apps
|── frappe
|── xhiveframework
├── custom_app
│   ├── README.md
│   ├── custom_app
@@ -25,7 +25,7 @@ frappe-bench
The commands module maybe a single file such as `commands.py` or a directory with an `__init__.py` file. For a custom application of name 'flags', example may be given as

```python
# file_path: frappe-bench/apps/flags/flags/commands.py
# file_path: xhiveframework-bench/apps/flags/flags/commands.py
import click

@click.command('set-flags')


+ 16
- 16
docs/bench_usage.md Прегледај датотеку

@@ -1,15 +1,15 @@
# bench CLI Usage

This may not be known to a lot of people but half the bench commands we're used to, exist in the Frappe Framework and not in bench directly. Those commands generally are the `--site` commands. This page is concerned only with the commands in the bench project. Any framework commands won't be a part of this consolidation.
This may not be known to a lot of people but half the bench commands we're used to, exist in the Xhive Framework and not in bench directly. Those commands generally are the `--site` commands. This page is concerned only with the commands in the bench project. Any framework commands won't be a part of this consolidation.


# bench CLI Commands

Under Click's structure, `bench` is the main command group, under which there are three main groups of commands in bench currently, namely

- **install**: The install command group deals with commands used to install system dependencies for setting up Frappe environment
- **install**: The install command group deals with commands used to install system dependencies for setting up Xhive environment

- **setup**: This command group for consists of commands used to maipulate the requirements and environments required by your Frappe environment
- **setup**: This command group for consists of commands used to maipulate the requirements and environments required by your Xhive environment

- **config**: The config command group deals with making changes in the current bench (not the CLI tool) configuration

@@ -20,7 +20,7 @@ Under Click's structure, `bench` is the main command group, under which there ar
➜ bench
Usage: bench [OPTIONS] COMMAND [ARGS]...

Bench manager for Frappe
Bench manager for Xhive

Options:
--version
@@ -70,7 +70,7 @@ These commands belong directly to the bench group so they can be invoked directl

### The usual commands

- **init**: Initialize a new bench instance in the specified path. This sets up a complete bench folder with an `apps` folder which contains all the Frappe apps available in the current bench, `sites` folder that stores all site data seperated by individual site folders, `config` folder that contains your redis, NGINX and supervisor configuration files. The `env` folder consists of all python dependencies the current bench and installed Frappe applications have.
- **init**: Initialize a new bench instance in the specified path. This sets up a complete bench folder with an `apps` folder which contains all the Xhive apps available in the current bench, `sites` folder that stores all site data seperated by individual site folders, `config` folder that contains your redis, NGINX and supervisor configuration files. The `env` folder consists of all python dependencies the current bench and installed Xhive applications have.
- **restart**: Restart web, supervisor, systemd processes units. Used in production setup.
- **update**: If executed in a bench directory, without any flags will backup, pull, setup requirements, build, run patches and restart bench. Using specific flags will only do certain tasks instead of all.
- **migrate-env**: Migrate Virtual Environment to desired Python version. This regenerates the `env` folder with the specified Python version.
@@ -80,15 +80,15 @@ These commands belong directly to the bench group so they can be invoked directl
- **backup**: Backup single site data. Can be used to backup files as well.
- **backup-all-sites**: Backup all sites in current bench.

- **get-app**: Download an app from the internet or filesystem and set it up in your bench. This clones the git repo of the Frappe project and installs it in the bench environment.
- **get-app**: Download an app from the internet or filesystem and set it up in your bench. This clones the git repo of the Xhive project and installs it in the bench environment.
- **remove-app**: Completely remove app from bench and re-build assets if not installed on any site.
- **exclude-app**: Exclude app from updating during a `bench update`
- **include-app**: Include app for updating. All Frappe applications are included by default when installed.
- **include-app**: Include app for updating. All Xhive applications are included by default when installed.
- **remote-set-url**: Set app remote url
- **remote-reset-url**: Reset app remote url to frappe official
- **remote-reset-url**: Reset app remote url to xhiveframework official
- **remote-urls**: Show apps remote url
- **switch-to-branch**: Switch all apps to specified branch, or specify apps separated by space
- **switch-to-develop**: Switch Frappe and ERPNext to develop branch
- **switch-to-develop**: Switch Xhive and XhiveERP to develop branch


### A little advanced
@@ -107,22 +107,22 @@ These commands belong directly to the bench group so they can be invoked directl

### Developer's commands

- **start**: Start Frappe development processes. Uses the Procfile to start the Frappe development environment.
- **start**: Start Xhive development processes. Uses the Procfile to start the Xhive development environment.
- **src**: Prints bench source folder path, which can be used to cd into the bench installation repository by `cd $(bench src)`.
- **find**: Finds benches recursively from location or specified path.
- **pip**: Use the current bench's pip to manage Python packages. For help about pip usage: `bench pip help [COMMAND]` or `bench pip [COMMAND] -h`.
- **new-app**: Create a new Frappe application under apps folder.
- **new-app**: Create a new Xhive application under apps folder.


### Release bench
- **release**: Create a release of a Frappe application
- **release**: Create a release of a Xhive application
- **prepare-beta-release**: Prepare major beta release from develop branch



## Setup commands

The setup commands used for setting up the Frappe environment in context of the current bench need to be executed using `bench setup` as the prefix. So, the general usage of these commands is as
The setup commands used for setting up the Xhive environment in context of the current bench need to be executed using `bench setup` as the prefix. So, the general usage of these commands is as

```zsh
bench setup COMMAND [ARGS]...
@@ -132,17 +132,17 @@ The setup commands used for setting up the Frappe environment in context of the

- **env**: Setup Python virtual environment for bench. This sets up a `env` folder under the root of the bench directory.
- **redis**: Generates configuration for Redis
- **fonts**: Add Frappe fonts to system
- **fonts**: Add Xhive fonts to system
- **config**: Generate or over-write sites/common_site_config.json
- **backups**: Add cronjob for bench backups
- **socketio**: Setup node dependencies for socketio server
- **requirements**: Setup Python and Node dependencies

- **manager**: Setup `bench-manager.local` site with the [Bench Manager](https://github.com/frappe/bench_manager) app, a GUI for bench installed on it.
- **manager**: Setup `bench-manager.local` site with the [Bench Manager](https://github.com/xhiveframework/bench_manager) app, a GUI for bench installed on it.

- **procfile**: Generate Procfile for bench start

- **production**: Setup Frappe production environment for specific user. This installs ansible, NGINX, supervisor, fail2ban and generates the respective configuration files.
- **production**: Setup Xhive production environment for specific user. This installs ansible, NGINX, supervisor, fail2ban and generates the respective configuration files.
- **nginx**: Generate configuration files for NGINX
- **fail2ban**: Setup fail2ban, an intrusion prevention software framework that protects computer servers from brute-force attacks
- **systemd**: Generate configuration for systemd


+ 2
- 2
docs/branch_details.md Прегледај датотеку

@@ -1,4 +1,4 @@
### ERPNext/Frappe Branching
### XhiveERP/Xhive Branching

#### Branch Description
- `develop` Branch: All new feature developments will go in develop branch
@@ -10,4 +10,4 @@
#### Where to send PR?
- If you are working on a new feature, then PR should point to develop branch
- If you are working on support issue / bug / error report, then PR should point to hotfix brach
- While performing testing on Staging branch, if any fix needed then only send that fix PR to staging.
- While performing testing on Staging branch, if any fix needed then only send that fix PR to staging.

+ 10
- 10
docs/commands_and_usage.md Прегледај датотеку

@@ -2,9 +2,9 @@

* Updating

To update the bench CLI tool, depending on your method of installation, you may use
To update the bench CLI tool, depending on your method of installation, you may use

pip3 install -U frappe-bench
pip3 install -U xhiveframework-bench


To backup, update all apps and sites on your bench, you may use
@@ -30,27 +30,27 @@ You can also run the parts of the bench selectively.

* Create a new bench

The init command will create a bench directory with frappe framework installed. It will be setup for periodic backups and auto updates once a day.
The init command will create a bench directory with xhive framework installed. It will be setup for periodic backups and auto updates once a day.

bench init frappe-bench && cd frappe-bench
bench init xhiveframework-bench && cd xhiveframework-bench

* Add a site

Frappe apps are run by frappe sites and you will have to create at least one site. The new-site command allows you to do that.
Xhive apps are run by xhiveframework sites and you will have to create at least one site. The new-site command allows you to do that.

bench new-site site1.local

* Add apps

The get-app command gets remote frappe apps from a remote git repository and installs them. Example: [erpnext](https://github.com/frappe/erpnext)
The get-app command gets remote xhiveframework apps from a remote git repository and installs them. Example: [xhiveerp](https://github.com/xhiveframework/xhiveerp)

bench get-app erpnext https://github.com/frappe/erpnext
bench get-app xhiveerp https://github.com/xhiveframework/xhiveerp

* Install apps

To install an app on your new site, use the bench `install-app` command.

bench --site site1.local install-app erpnext
bench --site site1.local install-app xhiveerp

* Start bench

@@ -58,7 +58,7 @@ You can also run the parts of the bench selectively.

bench start

To login to Frappe / ERPNext, open your browser and go to `[your-external-ip]:8000`, probably `localhost:8000`
To login to Xhive / XhiveERP, open your browser and go to `[your-external-ip]:8000`, probably `localhost:8000`

The default username is "Administrator" and password is what you set when you created the new site.

@@ -69,6 +69,6 @@ You can also run the parts of the bench selectively.
bench setup manager

1. Create new site bench-manager.local
2. Gets the `bench_manager` app from https://github.com/frappe/bench_manager if it doesn't exist already
2. Gets the `bench_manager` app from https://github.com/xhiveframework/bench_manager if it doesn't exist already
3. Installs the bench_manager app on the site bench-manager.local


+ 5
- 5
docs/contribution_guidelines.md Прегледај датотеку

@@ -18,8 +18,8 @@ We will strive for a "Zero Pull Request Pending" policy, inspired by "Zero Inbox

Please read the following design guidelines carefully when contributing:

1. [Form Design Guidelines](https://github.com/frappe/erpnext/wiki/Form-Design-Guidelines)
1. [How to break large contributions into smaller ones](https://github.com/frappe/erpnext/wiki/Cascading-Pull-Requests)
1. [Form Design Guidelines](https://github.com/xhiveframework/xhiveerp/wiki/Form-Design-Guidelines)
1. [How to break large contributions into smaller ones](https://github.com/xhiveframework/xhiveerp/wiki/Cascading-Pull-Requests)

### Pull Request Requirements

@@ -29,13 +29,13 @@ Please read the following design guidelines carefully when contributing:
1. **Explanation:** Include explanation if there is a design change, explain the use case and why this suggested change is better. If you are including a new library or replacing one, please give sufficient reference of why the suggested library is better.
1. **Demo:** Remember to update the demo script so that data related your feature is included in the demo.
1. **Failing Tests:** This is simple, you must make sure all automated tests are passing.
1. **Very Large Contribution:** It is very hard to accept and merge very large contributions, because there are too many lines of code to check and its implications can be large and unexpected. They way to contribute big features is to build them part by part. We can understand there are exceptions, but in most cases try and keep your pull-request to **30 lines of code** excluding tests and config files. **Use [Cascading Pull Requests](https://github.com/frappe/erpnext/wiki/Cascading-Pull-Requests)** for large features.
1. **Very Large Contribution:** It is very hard to accept and merge very large contributions, because there are too many lines of code to check and its implications can be large and unexpected. They way to contribute big features is to build them part by part. We can understand there are exceptions, but in most cases try and keep your pull-request to **30 lines of code** excluding tests and config files. **Use [Cascading Pull Requests](https://github.com/xhiveframework/xhiveerp/wiki/Cascading-Pull-Requests)** for large features.
1. **Incomplete Contributions must be hidden:** If the contribution is WIP or incomplete - which will most likely be the case, you can send small PRs as long as the user is not exposed to unfinished functionality. This will ensure that your code does not have build or other collateral issues. But these features must remain completely hidden to the user.
1. **Incorrect Patches:** If your design involves schema change and you must include patches that update the data as per your new schema.
1. **Incorrect Naming:** The naming of variables, models, fields etc must be consistent as per the existing design and semantics used in the system.
1. **Translated Strings:** All user facing strings / text must be wrapped in the `__("")` function in javascript and `_("")` function in Python, so that it is shown as translated to the user.
1. **Deprecated API:** The API used in the pull request must be the latest recommended methods and usage of globals like `cur_frm` must be avoided.
1. **Whitespace and indentation:** The ERPNext and Frappe Project uses tabs (I know and we are sorry, but its too much effort to change it now and we don't want to lose the history). The indentation must be consistent whether you are writing Javascript or Python. Multi-line strings or expressions must also be consistently indented, not hanging like a bee hive at the end of the line. We just think the code looks a lot more stable that way.
1. **Whitespace and indentation:** The XhiveERP and Xhive Project uses tabs (I know and we are sorry, but its too much effort to change it now and we don't want to lose the history). The indentation must be consistent whether you are writing Javascript or Python. Multi-line strings or expressions must also be consistently indented, not hanging like a bee hive at the end of the line. We just think the code looks a lot more stable that way.

#### What if my Pull Request is closed?

@@ -43,4 +43,4 @@ Don't worry, fix the problem and re-open it!

#### Why do we follow this policy?

This is because ERPNext is at a stage where it is being used by thousands of companies and introducing breaking changes can be harmful for everyone. Also we do not want to stop the speed of contributions and the best way to encourage contributors is to give fast feedback.
This is because XhiveERP is at a stage where it is being used by thousands of companies and introducing breaking changes can be harmful for everyone. Also we do not want to stop the speed of contributions and the best way to encourage contributors is to give fast feedback.

+ 7
- 7
docs/installation.md Прегледај датотеку

@@ -2,18 +2,18 @@

You will need a computer/server. Options include:

- A Normal Computer/VPS/Baremetal Server: This is strongly recommended. Frappe/ERPNext installs properly and works well on these
- A Raspberry Pi, SAN Appliance, Network Router, Gaming Console, etc.: Although you may be able to install Frappe/ERPNext on specialized hardware, it is unlikely to work well and will be difficult for us to support. Strongly consider using a normal computer/VPS/baremetal server instead. **We do not support specialized hardware**.
- A Toaster, Car, Firearm, Thermostat, etc.: Yes, many modern devices now have embedded computing capability. We live in interesting times. However, you should not install Frappe/ERPNext on these devices. Instead, install it on a normal computer/VPS/baremetal server. **We do not support installing on noncomputing devices**.
- A Normal Computer/VPS/Baremetal Server: This is strongly recommended. Xhive/XhiveERP installs properly and works well on these
- A Raspberry Pi, SAN Appliance, Network Router, Gaming Console, etc.: Although you may be able to install Xhive/XhiveERP on specialized hardware, it is unlikely to work well and will be difficult for us to support. Strongly consider using a normal computer/VPS/baremetal server instead. **We do not support specialized hardware**.
- A Toaster, Car, Firearm, Thermostat, etc.: Yes, many modern devices now have embedded computing capability. We live in interesting times. However, you should not install Xhive/XhiveERP on these devices. Instead, install it on a normal computer/VPS/baremetal server. **We do not support installing on noncomputing devices**.

To install the Frappe/ERPNext server software, you will need an operating system on your normal computer which is not Windows. Note that the command line interface does work on Windows, and you can use Frappe/ERPNext from any operating system with a web browser. However, the server software does not run on Windows. It does run on other operating systems, so choose one of these instead:
To install the Xhive/XhiveERP server software, you will need an operating system on your normal computer which is not Windows. Note that the command line interface does work on Windows, and you can use Xhive/XhiveERP from any operating system with a web browser. However, the server software does not run on Windows. It does run on other operating systems, so choose one of these instead:

- Linux: Ubuntu, Debian, CentOS are the preferred distros and are tested. [Arch Linux](https://github.com/frappe/bench/wiki/Install-ERPNext-on-ArchLinux) can also be used
- Linux: Ubuntu, Debian, CentOS are the preferred distros and are tested. [Arch Linux](https://github.com/xhiveframework/bench/wiki/Install-XhiveERP-on-ArchLinux) can also be used
- Mac OS X

### Manual Install

To manually install frappe/erpnext, you can follow this [this wiki](https://github.com/frappe/frappe/wiki/The-Hitchhiker%27s-Guide-to-Installing-Frappe-on-Linux) for Linux and [this wiki](https://github.com/frappe/frappe/wiki/The-Hitchhiker's-Guide-to-Installing-Frappe-on-Mac-OS-X) for MacOS. It gives an excellent explanation about the stack. You can also follow the steps mentioned below:
To manually install xhiveframework/xhiveerp, you can follow this [this wiki](https://lab.membtech.com/xhiveframework/xhiveframework/wiki/The-Hitchhiker%27s-Guide-to-Installing-Xhive-on-Linux) for Linux and [this wiki](https://lab.membtech.com/xhiveframework/xhiveframework/wiki/The-Hitchhiker's-Guide-to-Installing-Xhive-on-Mac-OS-X) for MacOS. It gives an excellent explanation about the stack. You can also follow the steps mentioned below:

#### 1. Install Prerequisites
<pre>
@@ -32,4 +32,4 @@ To manually install frappe/erpnext, you can follow this [this wiki](https://gith

Install the latest bench using pip

pip3 install frappe-bench
pip3 install xhiveframework-bench

+ 1
- 1
docs/release_policy.md Прегледај датотеку

@@ -39,7 +39,7 @@

- QA will use staging for testing.

- Deploy staging branch on frappe.io, erpnext.org, frappe.erpnext.com.
- Deploy staging branch on xhive.io, xhiveerp.org, xhiveframework.xhiveerp.com.

- Only regression and security fixes can be cherry-picked into staging



+ 7
- 7
docs/releasing_frappe_apps.md Прегледај датотеку

@@ -1,13 +1,13 @@
# Releasing Frappe ERPNext
# Releasing Xhive XhiveERP

* Make a new bench dedicated for releasing
```
bench init release-bench --frappe-path git@github.com:frappe/frappe.git
bench init release-bench --xhiveframework-path git@github.com:xhiveframework/xhiveframework.git
```

* Get ERPNext in the release bench
* Get XhiveERP in the release bench
```
bench get-app erpnext git@github.com:frappe/erpnext.git
bench get-app xhiveerp git@github.com:xhiveframework/xhiveerp.git
```

* Configure as release bench. Add this to the common_site_config.json
@@ -29,13 +29,13 @@ Usage: bench release [OPTIONS] APP BUMP_TYPE
```

* Arguments :
* _APP_ App name e.g [frappe|erpnext|yourapp]
* _APP_ App name e.g [xhiveframework|xhiveerp|yourapp]
* _BUMP_TYPE_ [major|minor|patch|stable|prerelease]
* Options:
* --from-branch git develop branch, default is develop
* --to-branch git master branch, default is master
* --remote git remote, default is upstream
* --owner git owner, default is frappe
* --owner git owner, default is xhiveframework
* --repo-name git repo name if different from app name
* When updating major version, update `develop_version` in hooks.py, e.g. `9.x.x-develop`

+ 26
- 26
easy-install.py Прегледај датотеку

@@ -41,23 +41,23 @@ def cprint(*args, level: int = 1):
print(CYLW, message, reset)


def clone_frappe_docker_repo() -> None:
def clone_xhiveframework_docker_repo() -> None:
try:
urllib.request.urlretrieve(
"https://github.com/frappe/frappe_docker/archive/refs/heads/main.zip",
"frappe_docker.zip",
"https://github.com/xhiveframework/xhiveframework_docker/archive/refs/heads/main.zip",
"xhiveframework_docker.zip",
)
logging.info("Downloaded frappe_docker zip file from GitHub")
logging.info("Downloaded xhiveframework_docker zip file from GitHub")
unpack_archive(
"frappe_docker.zip", "."
) # Unzipping the frappe_docker.zip creates a folder "frappe_docker-main"
move("frappe_docker-main", "frappe_docker")
logging.info("Unzipped and Renamed frappe_docker")
os.remove("frappe_docker.zip")
"xhiveframework_docker.zip", "."
) # Unzipping the xhiveframework_docker.zip creates a folder "xhiveframework_docker-main"
move("xhiveframework_docker-main", "xhiveframework_docker")
logging.info("Unzipped and Renamed xhiveframework_docker")
os.remove("xhiveframework_docker.zip")
logging.info("Removed the downloaded zip file")
except Exception as e:
logging.error("Download and unzip failed", exc_info=True)
cprint("\nCloning frappe_docker Failed\n\n", "[ERROR]: ", e, level=1)
cprint("\nCloning xhiveframework_docker Failed\n\n", "[ERROR]: ", e, level=1)


def get_from_env(dir, file) -> Dict:
@@ -77,15 +77,15 @@ def write_to_env(
db_pass: str,
admin_pass: str,
email: str,
erpnext_version: str = None,
xhiveerp_version: str = None,
) -> None:
site_name = site or ""
example_env = get_from_env(wd, "example.env")
erpnext_version = erpnext_version or example_env["ERPNEXT_VERSION"]
xhiveerp_version = xhiveerp_version or example_env["XHIVEERP_VERSION"]
with open(os.path.join(wd, ".env"), "w") as f:
f.writelines(
[
f"ERPNEXT_VERSION={erpnext_version}\n", # defaults to latest version of ERPNext
f"XHIVEERP_VERSION={xhiveerp_version}\n", # defaults to latest version of XhiveERP
f"DB_PASSWORD={db_pass}\n",
"DB_HOST=db\n",
"DB_PORT=3306\n",
@@ -93,7 +93,7 @@ def write_to_env(
"REDIS_QUEUE=redis-queue:6379\n",
"REDIS_SOCKETIO=redis-socketio:6379\n",
f"LETSENCRYPT_EMAIL={email}\n",
f"FRAPPE_SITE_NAME_HEADER={site_name}\n",
f"XHIVEFRAMEWORK_SITE_NAME_HEADER={site_name}\n",
f"SITE_ADMIN_PASS={admin_pass}",
]
)
@@ -111,15 +111,15 @@ def generate_pass(length: int = 12) -> str:


def check_repo_exists() -> bool:
return os.path.exists(os.path.join(os.getcwd(), "frappe_docker"))
return os.path.exists(os.path.join(os.getcwd(), "xhiveframework_docker"))


def setup_prod(project: str, sitename: str, email: str, version: str = None) -> None:
if check_repo_exists():
compose_file_name = os.path.join(os.path.expanduser("~"), f"{project}-compose.yml")
docker_repo_path = os.path.join(os.getcwd(), "frappe_docker")
docker_repo_path = os.path.join(os.getcwd(), "xhiveframework_docker")
cprint(
"\nPlease refer to .example.env file in the frappe_docker folder to know which keys to set\n\n",
"\nPlease refer to .example.env file in the xhiveframework_docker folder to know which keys to set\n\n",
level=3,
)
admin_pass = ""
@@ -142,7 +142,7 @@ def setup_prod(project: str, sitename: str, email: str, version: str = None) ->
admin_pass = env["SITE_ADMIN_PASS"]
db_pass = env["DB_PASSWORD"]
try:
# TODO: Include flags for non-https and non-erpnext installation
# TODO: Include flags for non-https and non-xhiveerp installation
subprocess.run(
[
which("docker"),
@@ -213,7 +213,7 @@ def setup_prod(project: str, sitename: str, email: str, version: str = None) ->
"--admin-password",
admin_pass,
"--install-app",
"erpnext",
"xhiveerp",
"--set-default",
],
check=True,
@@ -225,7 +225,7 @@ def setup_prod(project: str, sitename: str, email: str, version: str = None) ->
sys.exit(1)
else:
install_docker()
clone_frappe_docker_repo()
clone_xhiveframework_docker_repo()
setup_prod(project, sitename, email, version) # Recursive


@@ -243,11 +243,11 @@ def setup_dev_instance(project: str):
"up",
"-d",
],
cwd=os.path.join(os.getcwd(), "frappe_docker"),
cwd=os.path.join(os.getcwd(), "xhiveframework_docker"),
check=True,
)
cprint(
"Please go through the Development Documentation: https://github.com/frappe/frappe_docker/tree/main/development to fully complete the setup.",
"Please go through the Development Documentation: https://github.com/xhiveframework/xhiveframework_docker/tree/main/development to fully complete the setup.",
level=2,
)
logging.info("Development Setup completed")
@@ -256,7 +256,7 @@ def setup_dev_instance(project: str):
cprint("Setting Up Development Environment Failed\n", e)
else:
install_docker()
clone_frappe_docker_repo()
clone_xhiveframework_docker_repo()
setup_dev_instance(project) # Recursion on goes brrrr


@@ -295,7 +295,7 @@ def install_docker():


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Install Frappe with Docker")
parser = argparse.ArgumentParser(description="Install Xhive with Docker")
parser.add_argument(
"-p", "--prod", help="Setup Production System", action="store_true"
)
@@ -308,12 +308,12 @@ if __name__ == "__main__":
help="The Site Name for your production site",
default="site1.local",
)
parser.add_argument("-n", "--project", help="Project Name", default="frappe")
parser.add_argument("-n", "--project", help="Project Name", default="xhiveframework")
parser.add_argument(
"--email", help="Add email for the SSL.", required="--prod" in sys.argv
)
parser.add_argument(
"-v", "--version", help="ERPNext version to install, defaults to latest stable"
"-v", "--version", help="XhiveERP version to install, defaults to latest stable"
)
args = parser.parse_args()
if args.dev:


+ 7
- 7
pyproject.toml Прегледај датотеку

@@ -1,11 +1,11 @@
[project]
name = "frappe-bench"
description = "CLI to manage Multi-tenant deployments for Frappe apps"
name = "xhiveframework-bench"
description = "CLI to manage Multi-tenant deployments for Xhive apps"
readme = "README.md"
license = "GPL-3.0-only"
requires-python = ">=3.7"
authors = [
{ name = "Frappe Technologies Pvt Ltd", email = "developers@frappe.io" },
{ name = "Xhive Technologies Pvt Ltd", email = "developers@xhive.io" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
@@ -37,10 +37,10 @@ dynamic = [
bench = "bench.cli:cli"

[project.urls]
Changelog = "https://github.com/frappe/bench/releases"
Documentation = "https://frappeframework.com/docs/user/en/bench"
Homepage = "https://frappe.io/bench"
Source = "https://github.com/frappe/bench"
Changelog = "https://github.com/xhiveframework/bench/releases"
Documentation = "https://xhiveframework.com/docs/user/en/bench"
Homepage = "https://xhive.io/bench"
Source = "https://github.com/xhiveframework/bench"

[build-system]
requires = [


Loading…
Откажи
Сачувај