Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ jobs:
python -m pip install --upgrade pip
pip install flake8==4.0.1
pip install bandit==1.7.8
pip install codespell==2.2.4
- name: Run Flake8
run: |
flake8
- name: Run Bandit
run: |
bandit -r .
- name: Run Spell Check
run: |
codespell --skip="*.md,venv,migrations,*.pyc"
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ repos:
- id: bandit
args: ["-r", ".", "-x", "**/venv/*"]
pass_filenames: false
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
args: ['--skip=*.md,venv,migrations,*.pyc']
4 changes: 3 additions & 1 deletion common/apps/organization/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def get_new_organization_handler():
@task(name="spacedf.tasks.new_organization", max_retries=3)
@transaction.atomic
def create_organization(id, name, slug_name, is_active, owner, created_at, updated_at):
logger.info(f"create_organization: owner_email={owner.get('email')}, org_slug={slug_name}")
logger.info(
f"create_organization: owner_email={owner.get('email')}, org_slug={slug_name}"
)

organization = Organization(
schema_name=slug_name,
Expand Down
4 changes: 2 additions & 2 deletions common/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def inner(self, **kwargs):
handler(self=self, **kwargs)
else:
handler(**kwargs)
except Exception as ex:
logger.exception(ex)
except Exception as e:
logger.exception(e)
self.retry(countdown=3**self.request.retries)

return inner
Expand Down
26 changes: 10 additions & 16 deletions common/rabitmq/rabbitmq_provisioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def list_vhosts(self) -> Set[str]:
for entry in response.json()
if entry.get("name") is not None
}
except requests.RequestException as exc: # noqa: BLE001
logger.error("Failed to list RabbitMQ vhosts: %s", exc)
except requests.RequestException as e:
logger.error("Failed to list RabbitMQ vhosts: %s", e)
return set()

def get_vhost_load(self, vhost_name: str) -> Dict:
Expand Down Expand Up @@ -181,11 +181,9 @@ def create_vhost(self, vhost_name: str) -> bool:
vhost=vhost_name,
connector_name=emqx_client.connector_name(vhost_name),
)
except Exception as exc: # noqa: BLE001
except Exception as e:
logger.warning(
"Failed to configure EMQX connector for new vhost %s: %s",
vhost_name,
exc,
f"Failed to configure EMQX connector for new vhost {vhost_name}: {str(e)}"
)
return True
except requests.RequestException as e:
Expand Down Expand Up @@ -357,9 +355,9 @@ def get_organization_slugs(
)
return slugs

except Exception as exc:
except Exception as e:
logger.warning(
f"Failed to retrieve organization slugs for vhost {vhost_name}: {exc}"
f"Failed to retrieve organization slugs for vhost {vhost_name}: {e}"
)
if exclude:
return []
Expand Down Expand Up @@ -478,11 +476,9 @@ def provision_tenant(
)

emqx_client.ensure_vhost_rule(vhost_name, existing_slugs)
except Exception as exc: # noqa: BLE001
except Exception as e:
logger.error(
"Failed to configure EMQX resources for org %s: %s",
org_slug,
exc,
f"Failed to configure EMQX resources for org {org_slug}: {str(e)}"
)

return {
Expand Down Expand Up @@ -566,11 +562,9 @@ def delete_tenant(self, vhost_name: str, org_slug: str = None) -> bool:
)

emqx_client.teardown_tenant(vhost_name, remaining_slugs)
except Exception as exc: # noqa: BLE001
except Exception as e:
logger.warning(
"Failed to teardown EMQX resources for org %s: %s",
org_slug,
exc,
f"Failed to teardown EMQX resources for org {org_slug}: {str(e)}"
)

return True
Expand Down