Skip to content

Commit bfbbd3b

Browse files
committed
[occupancy] Create the occupancy project
1 parent b0acf75 commit bfbbd3b

File tree

15 files changed

+3183
-2354
lines changed

15 files changed

+3183
-2354
lines changed

projects/core/uoft_core/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def callback(
5858
"grist",
5959
"librenms",
6060
"nautobot",
61+
"occupancy",
6162
"paloalto",
6263
"phpipam",
6364
"scripts",

projects/core/uoft_core/tests/regression_tests.py

Lines changed: 81 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,131 @@
11

22
# [[[cog import _cog; _cog.all_importable_modules()]]]
33
importable_modules = [
4-
"uoft_grist.cli",
5-
"uoft_grist",
6-
"uoft_snipeit.print",
7-
"uoft_snipeit.cli",
8-
"uoft_snipeit",
9-
"uoft_snipeit.mkinventorylabel",
10-
"uoft_snipeit.location_lookup",
11-
"uoft_snipeit.create",
12-
"uoft_snipeit.serial_lookup",
13-
"uoft_snipeit.batch",
14-
"uoft_snipeit.generate",
15-
"uoft_snipeit.checkout",
16-
"uoft_snipeit.api",
4+
"uoft_phpipam.ansible_lookup",
175
"uoft_phpipam.cli",
18-
"uoft_phpipam",
196
"uoft_phpipam.serial_lookup",
20-
"uoft_phpipam.ansible_lookup",
7+
"uoft_phpipam",
218
"uoft_phpipam.api",
22-
"uoft_librenms.cli",
239
"uoft_librenms.typing",
10+
"uoft_librenms.cli",
2411
"uoft_librenms",
2512
"uoft_librenms.api",
26-
"uoft_aruba.cli",
27-
"uoft_aruba",
28-
"uoft_aruba.batch",
29-
"uoft_aruba.api",
30-
"uoft_aruba.cli_commands.station_blocklist",
31-
"uoft_aruba.cli_commands",
32-
"uoft_aruba.cli_commands.list_aps",
33-
"uoft_aruba.cli_commands.cpsec_allowlist",
34-
"uoft_nautobot.datasources",
35-
"uoft_nautobot",
36-
"uoft_nautobot.jinja_filters",
37-
"uoft_nautobot.auth",
38-
"uoft_nautobot.urls",
39-
"uoft_nautobot.secrets",
40-
"uoft_nautobot.template_content",
41-
"uoft_nautobot.golden_config",
42-
"uoft_nautobot.excel",
43-
"uoft_nautobot.api",
44-
"uoft_nautobot.api.views",
45-
"uoft_nautobot.api.urls",
4613
"uoft_paloalto.cli",
4714
"uoft_paloalto",
4815
"uoft_paloalto.api",
49-
"uoft_bluecat.cli",
50-
"uoft_bluecat.type_stubs",
51-
"uoft_bluecat",
52-
"uoft_bluecat.api",
16+
"uoft_ssh.pexpect_utils",
17+
"uoft_ssh.util",
5318
"uoft_ssh.cli",
5419
"uoft_ssh",
55-
"uoft_ssh.util",
56-
"uoft_ssh.pexpect_utils",
20+
"uoft_snipeit.print",
21+
"uoft_snipeit.cli",
22+
"uoft_snipeit.create",
23+
"uoft_snipeit.mkinventorylabel",
24+
"uoft_snipeit.checkout",
25+
"uoft_snipeit.serial_lookup",
26+
"uoft_snipeit.batch",
27+
"uoft_snipeit",
28+
"uoft_snipeit.generate",
29+
"uoft_snipeit.api",
30+
"uoft_snipeit.location_lookup",
31+
"uoft_occupancy.cli",
32+
"uoft_occupancy",
5733
"uoft_scripts.cli",
58-
"uoft_scripts",
5934
"uoft_scripts._sync",
60-
"uoft_scripts._jinja",
6135
"uoft_scripts.arista",
36+
"uoft_scripts",
6237
"uoft_scripts.nornir",
38+
"uoft_scripts._jinja",
39+
"uoft_scripts.stg_ipam_dev.cli",
40+
"uoft_scripts.stg_ipam_dev.lib",
41+
"uoft_scripts.stg_ipam_dev",
6342
"uoft_scripts.sib_turnup.cli",
64-
"uoft_scripts.sib_turnup",
6543
"uoft_scripts.sib_turnup.lib",
44+
"uoft_scripts.sib_turnup",
6645
"uoft_scripts.librenms.cli",
67-
"uoft_scripts.librenms",
6846
"uoft_scripts.librenms.lib",
69-
"uoft_scripts.nautobot.cli",
70-
"uoft_scripts.nautobot",
71-
"uoft_scripts.nautobot.lib",
72-
"uoft_scripts.stg_ipam_dev.cli",
73-
"uoft_scripts.stg_ipam_dev",
74-
"uoft_scripts.stg_ipam_dev.lib",
47+
"uoft_scripts.librenms",
7548
"uoft_scripts.ldap.cli",
76-
"uoft_scripts.ldap",
7749
"uoft_scripts.ldap.lib",
50+
"uoft_scripts.ldap",
51+
"uoft_scripts.nautobot.cli",
52+
"uoft_scripts.nautobot.lib",
53+
"uoft_scripts.nautobot",
7854
"uoft_scripts.arista.cli",
79-
"uoft_scripts.arista",
8055
"uoft_scripts.arista.lib",
56+
"uoft_scripts.arista",
57+
"uoft_nautobot.datasources",
58+
"uoft_nautobot.urls",
59+
"uoft_nautobot.secrets",
60+
"uoft_nautobot.excel",
61+
"uoft_nautobot",
62+
"uoft_nautobot.golden_config",
63+
"uoft_nautobot.jinja_filters",
64+
"uoft_nautobot.template_content",
65+
"uoft_nautobot.auth",
66+
"uoft_nautobot.api.views",
67+
"uoft_nautobot.api.urls",
68+
"uoft_nautobot.api",
69+
"uoft_aruba.cli",
70+
"uoft_aruba.batch",
71+
"uoft_aruba",
72+
"uoft_aruba.api",
73+
"uoft_aruba.cli_commands.station_blocklist",
74+
"uoft_aruba.cli_commands.cpsec_allowlist",
75+
"uoft_aruba.cli_commands",
76+
"uoft_aruba.cli_commands.list_aps",
77+
"uoft_switchconfig.deploy",
78+
"uoft_switchconfig.util",
8179
"uoft_switchconfig.cli",
8280
"uoft_switchconfig",
83-
"uoft_switchconfig.util",
84-
"uoft_switchconfig.__main__",
8581
"uoft_switchconfig.generate",
8682
"uoft_switchconfig.types",
87-
"uoft_switchconfig.deploy",
83+
"uoft_switchconfig.__main__",
8884
"uoft_switchconfig.example_template_dir",
89-
"uoft_core.logging",
9085
"uoft_core.typing",
86+
"uoft_core.console",
9187
"uoft_core.other",
9288
"uoft_core",
9389
"uoft_core.jinja_library",
94-
"uoft_core.console",
95-
"uoft_core.__main__",
96-
"uoft_core.nested_data",
9790
"uoft_core.prompt",
91+
"uoft_core.logging",
9892
"uoft_core.types",
93+
"uoft_core.nested_data",
9994
"uoft_core.api",
100-
"uoft_core.toml",
95+
"uoft_core.__main__",
10196
"uoft_core.toml._re",
102-
"uoft_core.toml._parser",
10397
"uoft_core.toml._writer",
104-
"uoft_core.yaml.scalarbool",
98+
"uoft_core.toml",
99+
"uoft_core.toml._parser",
100+
"uoft_core.yaml.representer",
101+
"uoft_core.yaml.util",
102+
"uoft_core.yaml.comments",
103+
"uoft_core.yaml.main",
104+
"uoft_core.yaml.serializer",
105105
"uoft_core.yaml.scanner",
106-
"uoft_core.yaml.emitter",
107-
"uoft_core.yaml",
106+
"uoft_core.yaml.io",
107+
"uoft_core.yaml.scalarint",
108+
"uoft_core.yaml.constructor",
108109
"uoft_core.yaml.nodes",
109-
"uoft_core.yaml.events",
110-
"uoft_core.yaml.util",
110+
"uoft_core.yaml.error",
111+
"uoft_core.yaml.emitter",
111112
"uoft_core.yaml.scalarfloat",
113+
"uoft_core.yaml.anchor",
114+
"uoft_core.yaml.compat",
115+
"uoft_core.yaml",
112116
"uoft_core.yaml.scalarstring",
113-
"uoft_core.yaml.parser",
114-
"uoft_core.yaml.main",
115117
"uoft_core.yaml.composer",
116-
"uoft_core.yaml.compat",
117-
"uoft_core.yaml.anchor",
118-
"uoft_core.yaml.tokens",
119118
"uoft_core.yaml.resolver",
120-
"uoft_core.yaml.scalarint",
121-
"uoft_core.yaml.constructor",
122-
"uoft_core.yaml.representer",
123-
"uoft_core.yaml.comments",
124-
"uoft_core.yaml.serializer",
119+
"uoft_core.yaml.events",
120+
"uoft_core.yaml.scalarbool",
121+
"uoft_core.yaml.tokens",
125122
"uoft_core.yaml.timestamp",
126-
"uoft_core.yaml.error",
127-
"uoft_core.yaml.io",
123+
"uoft_core.yaml.parser",
124+
"uoft_grist.cli",
125+
"uoft_grist",
126+
"uoft_bluecat.cli",
127+
"uoft_bluecat",
128+
"uoft_bluecat.api",
128129
]
129130
# [[[end]]]
130131

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2+
_src_path: tasks/_new_project/template
3+
author_email: kyle.fozo@utoronto.ca
4+
author_name: Kyle-Fozo
5+
description: Occupancy tracking
6+
name: occupancy

projects/occupancy/README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# uoft_occupancy
2+
3+
Occupancy tracking
4+
5+
## Installation
6+
7+
### Requirements
8+
9+
This software requires Python3.10 or higher.
10+
We recommend you install this software with [pipx](https://pypa.github.io/pipx/):
11+
12+
### MacOS / Linux
13+
14+
```console
15+
$ python3.10 -m pip install --user pipx
16+
$ pipx install uoft_occupancy
17+
```
18+
19+
If you don't have or cannot easily get python3.10, you can run the following commands to download a standalone python3.10 binary and use it to install pipx:
20+
21+
```console
22+
$ curl -L https://github.com/uoft-networking/tools/releases/download/1.1.0/ensure-python.py
23+
24+
$ python ensure-python.py pipx
25+
# You can use python2 or python3 to run this script
26+
27+
```
28+
29+
### Windows
30+
31+
Install [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) and the [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-ca&gl=ca) and then follow the instructions for MacOS / Linux above.
32+
33+
## Configuration
34+
35+
Configuration for this application is loaded from multiple sources. All configuration from all sources is merged together. In the event of configuration conflicts, the configuration from the last source will take precedence.
36+
37+
Configuration is loaded from the following sources in order:
38+
39+
1. Configuration files in the following locations:
40+
Linux:
41+
- `/etc/xdg/uoft-tools/shared.ini`
42+
- `/etc/xdg/uoft-tools/shared.yaml`
43+
- `/etc/xdg/uoft-tools/shared.json`
44+
- `/etc/xdg/uoft-tools/shared.toml`
45+
- `/etc/xdg/uoft-tools/occupancy.ini`
46+
- `/etc/xdg/uoft-tools/occupancy.yaml`
47+
- `/etc/xdg/uoft-tools/occupancy.json`
48+
- `/etc/xdg/uoft-tools/occupancy.toml`
49+
- `~/.config/uoft-tools/shared.ini`
50+
- `~/.config/uoft-tools/shared.yaml`
51+
- `~/.config/uoft-tools/shared.json`
52+
- `~/.config/uoft-tools/shared.toml`
53+
- `~/.config/uoft-tools/occupancy.ini`
54+
- `~/.config/uoft-tools/occupancy.yaml`
55+
- `~/.config/uoft-tools/occupancy.json`
56+
- `~/.config/uoft-tools/occupancy.toml`
57+
58+
MacOS:
59+
- `/Library/Preferences/uoft-tools/shared.ini`
60+
- `/Library/Preferences/uoft-tools/shared.yaml`
61+
- `/Library/Preferences/uoft-tools/shared.json`
62+
- `/Library/Preferences/uoft-tools/shared.toml`
63+
- `/Library/Preferences/uoft-tools/occupancy.ini`
64+
- `/Library/Preferences/uoft-tools/occupancy.yaml`
65+
- `/Library/Preferences/uoft-tools/occupancy.json`
66+
- `/Library/Preferences/uoft-tools/occupancy.toml`
67+
- `~/.config/uoft-tools/shared.ini`
68+
- `~/.config/uoft-tools/shared.yaml`
69+
- `~/.config/uoft-tools/shared.json`
70+
- `~/.config/uoft-tools/shared.toml`
71+
- `~/.config/uoft-tools/occupancy.ini`
72+
- `~/.config/uoft-tools/occupancy.yaml`
73+
- `~/.config/uoft-tools/occupancy.json`
74+
- `~/.config/uoft-tools/occupancy.toml`
75+
- `~/Library/Preferences/uoft-tools/shared.ini`
76+
- `~/Library/Preferences/uoft-tools/shared.yaml`
77+
- `~/Library/Preferences/uoft-tools/shared.json`
78+
- `~/Library/Preferences/uoft-tools/shared.toml`
79+
- `~/Library/Preferences/uoft-tools/occupancy.ini`
80+
- `~/Library/Preferences/uoft-tools/occupancy.yaml`
81+
- `~/Library/Preferences/uoft-tools/occupancy.json`
82+
- `~/Library/Preferences/uoft-tools/occupancy.toml`
83+
84+
85+
The site-wide config directory (`/etc/xdg/uoft-tools` or `/Library/Preferences` in the above example) can be overridden by setting the `OCCUPANCY_SITE_CONFIG` environment variable.
86+
87+
The user config directory (`~/.config/uoft-tools` or `~/Library/Preferences` in the above example) can be overridden by setting the `OCCUPANCY_USER_CONFIG` environment variable.
88+
89+
2. [Pass](https://www.passwordstore.org/) secret named `uoft-occupancy` (if available). Configuration stored in pass must be written in [TOML](https://toml.io/en/) format.
90+
91+
3. Environment variables. Environment variables are loaded from the `OCCUPANCY_` namespace. For example, the `foo` configuration option can be set by setting the `OCCUPANCY_FOO` environment variable.
92+
93+
Configuration Options:
94+
<!--
95+
[[[cog
96+
import _cog as c; c.gen_conf_table('uoft_occupancy')
97+
]]] -->
98+
| Option | Type | Title | Description | Default |
99+
| ------ | ---- | ----- | ----------- | ------- |
100+
| psql_database | str | | | annotation=NoneType required=True title='PSQL Database name' description='The username used to manage the PSQL database.' |
101+
| psql_host | str | | | annotation=NoneType required=True title='PSQL hostname' description='The hostname of the PSQL database.' |
102+
| psql_user | str | | | annotation=NoneType required=True title='PSQL username' description='The username used to manage the PSQL database.' |
103+
| psql_password | SecretStr | | | annotation=NoneType required=True title='PSQL database password' description='The password used to manage the PSQL database.' |
104+
| psql_port | str | | | annotation=NoneType required=True title='PSQL database port' description='The port for the database on the host' |
105+
| aruba_svc_account | str | | | annotation=NoneType required=True title='Aruba API Authentication Account' description="Account used to log into the API of Aruba 'Managed Devices'." |
106+
| aruba_svc_password | SecretStr | | | annotation=NoneType required=True title='Aruba API Authentication Password' description="Password used to log into the API of Aruba 'Managed Devices'." |
107+
| aruba_md_hostnames | str | | | annotation=NoneType required=True title='Aruba Controller (Managed Device) IP Adresses / Hostnames' description='A list of Aruba MD names to query.' |
108+
| aruba_default_config_path | str | | | annotation=NoneType required=True title='Aruba API Default Config Path' description="Default config path used for API requests of Aruba 'Managed Devices'." |
109+
| global_ranges | str | | | annotation=NoneType required=True title='Global column ranges' description='List used in conjunction with unique users.' |
110+
| filter_ranges | str | | | annotation=NoneType required=True title='Global filter ranges' description='Used to count unique users.' |
111+
| departments | Department | | | annotation=NoneType required=True title='Departmental Models' description='Any number of departmental models can be created as long as they follow the class format defined.' |
112+
<!--[[[end]]] -->
113+
114+
## License
115+
116+
MIT

projects/occupancy/pyproject.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
3+
def pdm_build_initialize(context):
4+
if "dependencies" in context.config_settings:
5+
target = context.config_settings["dependencies"]
6+
import re
7+
from pathlib import Path
8+
import subprocess
9+
10+
monorepo_root = Path(__file__).parent.parent.parent
11+
12+
# TODO: find out if python build frontends like pip ALWAYS initialize submodules
13+
# if so, this call won't be necessary
14+
subprocess.run(["git", "submodule", "init"], cwd=monorepo_root)
15+
forks_dir = monorepo_root / "custom-forks"
16+
forks = {fork.name: fork for fork in forks_dir.iterdir() if fork.is_dir() and not fork.name.startswith("_")}
17+
18+
if target == "local":
19+
20+
def local_dependency(name: str):
21+
if name.startswith("uoft_"):
22+
proj_name = name.partition(" ")[0].partition("uoft_")[2]
23+
proj_dir = monorepo_root / "projects" / proj_name
24+
if proj_dir.exists():
25+
return f"{name} @ file://{proj_dir}"
26+
base_name = re.split(r" |<|>|!|=|~|@|\[", name)[0]
27+
if base_name in forks:
28+
extras = re.search(r"\[.*\]", name)
29+
if extras:
30+
base_name = f"{base_name}{extras.group()}"
31+
return f"{base_name} @ file://{forks[base_name]}"
32+
return name
33+
34+
metadata = context.config.metadata
35+
metadata["dependencies"] = [local_dependency(dep) for dep in metadata["dependencies"]]
36+
print("Local dependencies selected")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy