Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
verhulstm committed Apr 1, 2024
0 parents commit fbb3df5
Show file tree
Hide file tree
Showing 99 changed files with 5,007 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
- name: Run bash-environment-manager
run: |
sudo rm /etc/apt/sources.list
sudo rm /etc/apt/sources.list.d/*
sudo curl https://raw.githubusercontent.com/terminal-labs-bem/shelf/main/prepfiles/sources.list --output /etc/apt/sources.list
mkdir -p .repo
curl https://raw.githubusercontent.com/terminal-labs-bem/shelf/main/prepfiles/clean_image.sh --output .repo/clean_image.sh
curl https://raw.githubusercontent.com/terminal-labs-bem/shelf/main/prepfiles/mock_vagrant.sh --output .repo/mock_vagrant.sh
sudo bash .repo/clean_image.sh
sudo bash .repo/mock_vagrant.sh
cd /vagrant; sudo su vagrant -c "sudo make venv.python"
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.coverage
auth

poetry.lock
package-lock.json
__pycache__
env
node_modules
.vagrant
\#*\#
*~
*egg-info
*.pyc
tmp
.tmp
activate.sh
keys.sh
.Trash*
20 changes: 20 additions & 0 deletions .repo/rules.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
renamedirs = [ "[repo]/src/factory",]
editlines = []
inherited = [
".github/workflows/build.yml",
"src/factory/settings.py",
"src/factory/config.py",
"src/factory/utils.py",
"src/factory/core.py",
"LICENSE",
"MANIFEST.in",
".gitignore",
"poetry.toml",
]
semiinherited = [
"Makefile",
"pyproject.toml",
"setup.cfg",
"setup.py",
"Taskfile.yml",
]
1 change: 1 addition & 0 deletions .repo/vars/basedon
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
standard
1 change: 1 addition & 0 deletions .repo/vars/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
72 changes: 72 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#####

Copyright © 2014, 2015, 2016, 2017 Beacon Solutions, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

#####

The MIT License (MIT)

Copyright (c) 2015 Andrey Petrov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

#####

Copyright (c) 2015-2019, Terminal Labs
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Terminal Labs nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL TERMINAL LABS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include src *
43 changes: 43 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
APPNAME=utilitiespackage
SUDOUSERNAME=$(SUDO_USER)
CONFIGURATION="default"
TYPE="python"
PYTHONVERSION="3.11"
HOSTTYPE="default"
INTERNALUSER=$(SUDO_USER)
PLATFORM=".tlcache"
PLUGIN="standard"
EXTRA="none"

help:
@echo "usage: make [command]"

define kickoff
@sudo bash .tmp/bem/common/preinstall.sh $(APPNAME) $(SUDOUSERNAME) $(CONFIGURATION) $(TYPE) $(PYTHONVERSION) $(HOSTTYPE) $(INTERNALUSER) $(PLATFORM) $(PLUGIN) $(EXTRA)
endef

download_bash_environment_manager:
@if test ! -d ".tmp";then \
sudo su -m $(SUDO_USER) -c "mkdir -p .tmp"; \
sudo su -m $(SUDO_USER) -c "mkdir -p .tmp/prep"; \
sudo su -m $(SUDO_USER) -c "mkdir -p .tmp/bem"; \
sudo su -m $(SUDO_USER) -c "mkdir -p .tmp/task"; \
sudo su -m $(SUDO_USER) -c "cd .tmp/prep; wget -O shelf-main.zip https://github.com/terminal-labs-bem/shelf/archive/refs/heads/main.zip"; \
sudo su -m $(SUDO_USER) -c "cd .tmp/prep; unzip -n shelf-main.zip"; \
sudo su -m $(SUDO_USER) -c "cp -r .tmp/prep/shelf-main/bem/* .tmp/bem"; \
sudo su -m $(SUDO_USER) -c "cp -r .tmp/prep/shelf-main/task/* .tmp/task"; \
fi

venv.python: HOSTTYPE="host"
venv.python: INTERNALUSER=$(SUDO_USER)
venv.python: download_bash_environment_manager
$(call kickoff)

vm.venv.python: HOSTTYPE="vagrant"
vm.venv.python: INTERNALUSER="vagrant"
vm.venv.python: download_bash_environment_manager
@if test ! -f "Vagrantfile";then \
wget https://raw.githubusercontent.com/terminal-labs/bash-environment-manager-shelf/main/vagrantfiles/Vagrantfile; \
chown $(SUDO_USER) Vagrantfile; \
fi
$(call kickoff)
Empty file added README.md
Empty file.
17 changes: 17 additions & 0 deletions dependencies/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
libssl-dev
zlib1g-dev
libbz2-dev
libreadline-dev
libsqlite3-dev
libffi-dev
libpq-dev
zip
unzip
tree
wget
nano
emacs
python3
python3-pip
python3-dev
python3-venv
81 changes: 81 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import sys
from setuptools import setup, find_packages

from utilitiespackage.settings import VERSION, MINIMUM_PYTHON_VERSION

assert sys.version_info >= MINIMUM_PYTHON_VERSION

setup(
name="utilities-package",
version=VERSION,
description="utilities package",
url="https://gitlab.com/terminallabs/utilitiespackage/utilities-package",
author="Terminal Labs",
author_email="[email protected]",
license="see LICENSE file",
packages=find_packages(),
zip_safe=False,
include_package_data=True,
install_requires=[
"setuptools",
"boltons",
"utilitybelt",
"numpy",
"algorithms",
"path.py",
"bash",
"sh",
"configparser",
"unidecode",
"PyYAML",
"ruamel.yaml",
"toml",
"simplejson",
"tailer",
"pytz",
"termcolor",
"texttable",
"click",
"typer",
"schedule",
"python-dateutil",
"beautifulsoup4",
"cssutils",
"istr",
"shortuuid",
"hashids",
"base58",
"bcrypt",
"aiohttp",
"uritools",
"sqlalchemy",
"montydb",
"requests",
"falcon",
"tornado",
"cherrypy",
"bottle",
"flask",
"fastapi",
"Jinja2",
"Genshi",
"Mako",
"Pillow",
"coverage",
"pycontracts",
"pytest",
"pytest-cov",
"pytest-mock",
"pytest-click",
"pytest-pylint",
"pytest-httpserver",
"black",
"flake8",
"radon",
"cli-passthrough",
],
entry_points="""
[console_scripts]
utilitiespackage=utilitiespackage.__main__:main
""",
)
3 changes: 3 additions & 0 deletions utilitiespackage/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
disable_warnings = module-not-measured, no-data-collected
omit = mock/*, tests/*, coverage.py, __main__.py, cli.py
Empty file added utilitiespackage/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions utilitiespackage/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from utilitiespackage.cli import main

main()
13 changes: 13 additions & 0 deletions utilitiespackage/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import requests


def api_is_up():
try:
r = requests.get("http://127.0.0.1:5000/api/v1.0/system/test")
response_dict = r.json()
if response_dict["status"] == "good":
return True
else:
return False
except requests.exceptions.ConnectionError as e: # This is the correct syntax
return False
Empty file added utilitiespackage/app.py
Empty file.
39 changes: 39 additions & 0 deletions utilitiespackage/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os
import sys
import click
import pytest

from utilitiespackage.settings import *

assert sys.version_info >= MINIMUM_PYTHON_VERSION


@click.group()
def cli():
return None


@click.group(name="system")
def system_group():
return None


@system_group.command(name="version")
def version_command():
print(VERSION)


@system_group.command(name="selftest")
def selftest_command():
os.chdir(TESTDIR)
pytest.main(["--disable-pytest-warnings", "-x", "-v", TESTDIR])


@system_group.command(name="selfcoverage")
def selfcoverage_command():
os.chdir(APPDIR)
pytest.main(["--disable-pytest-warnings", f"--cov-config={COVERAGERC_PATH}", "--cov=utilitiespackage", "--cov-report", "term-missing", APPDIR])


cli.add_command(system_group)
main = cli
14 changes: 14 additions & 0 deletions utilitiespackage/configs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import json

from utilitiespackage.fs import list_files_in_dir, list_dirs_in_dir


def get_json_dict_from_dir(name, dir):
assert len(list_dirs_in_dir(dir)) == 0
raw_names = list_files_in_dir(dir)
names = [os.path.splitext(x)[0] for x in raw_names]
if name in names:
with open(os.path.join(dir, name + ".json"), "r") as f:
dic = json.load(f)
return dic
Loading

0 comments on commit fbb3df5

Please sign in to comment.