Skip to content

Commit

Permalink
pin pypi release action
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheider committed Sep 16, 2022
1 parent 4b56237 commit 9147ade
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 124 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ jobs:
env:
test_pypi_password: ${{ secrets.test_pypi_secret }}
if: env.test_pypi_password != null && endsWith(github.ref, 'master') && github.repository_owner == 'aivclab'
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.test_pypi_secret }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
env:
pypi_password: ${{ secrets.pypi_secret }}
if: env.pypi_password != null && startsWith(github.ref, 'refs/tags') && github.repository_owner == 'aivclab'
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.pypi_secret }}
#verbose: true
Expand Down
20 changes: 2 additions & 18 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Neo documentation build configuration file, created by
# sphinx-quickstart on Tue Jul 25 10:23:12 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#

import sys
from pathlib import Path
Expand Down Expand Up @@ -110,7 +94,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = []
exclude_patterns = ['**/*exclude*', '**/*Exclude*']

# The name of the Pygments (syntax highlighting) style to use.
highlight_language = "python"
Expand Down Expand Up @@ -142,7 +126,7 @@
# "display_version": False,
}

html_baseurl = f"aivclab.github.io/{PROJECT_NAME}"
html_baseurl = f"{PROJECT_ORGANISATION}.github.io/{PROJECT_NAME}"

# -- Options for HTMLHelp output ------------------------------------------

Expand Down
34 changes: 14 additions & 20 deletions heimdallr/configuration/heimdallr_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from sorcery import assigned_names

from apppath import ensure_existence
from warg import ensure_existence
from heimdallr import PROJECT_APP_PATH
from warg import PropertySettings, is_windows

Expand Down Expand Up @@ -182,14 +182,11 @@ def google_calendar_id(self, calendar_id: str) -> None:

@google_calendar_id.deleter
def google_calendar_id(self) -> None:
"""
Args:
calendar_id ():
'''
Returns:
"""
:return:
:rtype:
'''
key = inspect.currentframe().f_code.co_name
with shelve.open(
str(HeimdallrSettings._github_settings_path), writeback=True
Expand Down Expand Up @@ -233,14 +230,11 @@ def github_token(self, calendar_id: str) -> None:

@github_token.deleter
def github_token(self) -> None:
"""
Args:
calendar_id ():
'''
Returns:
"""
:return:
:rtype:
'''
key = inspect.currentframe().f_code.co_name
with shelve.open(
str(HeimdallrSettings._github_settings_path), writeback=True
Expand Down Expand Up @@ -468,18 +462,18 @@ def set_all_heimdallr_settings(
**kwargs,
):
"""description"""
HEIMDALLR_SETTINGS = HeimdallrSettings(setting_scope)
# print(f"current heimdallr settings: {HEIMDALLR_SETTINGS}")
heimdallr_settings = HeimdallrSettings(setting_scope)
# print(f"current heimdallr settings: {heimdallr_settings}")
if _lower_keys:
kwargs = {k.lower(): v for k, v in kwargs.items()}

# for k in kwargs.keys():
# assert k in HEIMDALLR_SETTINGS, f'"{k}" is not in Heimdallrs settings'
# assert k in heimdallr_settings, f'"{k}" is not in Heimdallrs settings'

for k in HEIMDALLR_SETTINGS:
for k in heimdallr_settings:
assert k in kwargs.keys(), f'Missing "{k}" from kwargs'

HEIMDALLR_SETTINGS.__from_dict__(kwargs)
heimdallr_settings.__from_dict__(kwargs)

print(f"new heimdallr settings: {HeimdallrSettings()}")

Expand Down
2 changes: 1 addition & 1 deletion heimdallr/entry_points/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def set(
"""Setting options: [mqtt_access_token, mqtt_username, mqtt_password, mqtt_broker, mqtt_port]"""
print(self.setting_scope)
settings = HeimdallrSettings(setting_scope=self.setting_scope)
print(settings._mqtt_settings_path)
print(settings._mqtt_settings_path) #TODO: ACCESS TO protected member
settings.__setattr__(setting, value)

def multi_set(self, **kw) -> None:
Expand Down
16 changes: 8 additions & 8 deletions heimdallr/entry_points/deprecated/publisher_non_sch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import time

import paho.mqtt.client as mqtt
from apppath import ensure_existence
from draugr import IgnoreInterruptSignal
from warg import ensure_existence
from warg import IgnoreInterruptSignal
from warg import busy_indicator
from draugr.writers import LogWriter, MockWriter, Writer
from warg import NOD
Expand Down Expand Up @@ -52,20 +52,20 @@ def main(is_user: bool = False):
client.on_publish = on_publish
client.on_disconnect = on_disconnect

HEIMDALLR_SETTINGS = HeimdallrSettings() # TODO input scope
heimdallr_settings = HeimdallrSettings() # TODO input scope

client.username_pw_set(
HEIMDALLR_SETTINGS.mqtt_username, HEIMDALLR_SETTINGS.mqtt_password
heimdallr_settings.mqtt_username, heimdallr_settings.mqtt_password
)
try:
client.connect(
HEIMDALLR_SETTINGS.mqtt_broker, HEIMDALLR_SETTINGS.mqtt_port, keepalive=60
heimdallr_settings.mqtt_broker, heimdallr_settings.mqtt_port, keepalive=60
)
except ValueError as ve:
raise ValueError(
f"{HEIMDALLR_SETTINGS._mqtt_settings_path},"
f"{HEIMDALLR_SETTINGS.mqtt_broker},"
f"{HEIMDALLR_SETTINGS.mqtt_port},"
f"{heimdallr_settings._mqtt_settings_path},"
f"{heimdallr_settings.mqtt_broker},"
f"{heimdallr_settings.mqtt_port},"
f"{ve}"
)
client.loop_start()
Expand Down
24 changes: 17 additions & 7 deletions heimdallr/entry_points/publisher.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "Christian Heider Nielsen"
__doc__ = r"""
Created on 19/03/2020
"""

import json
import socket
import time
from typing import Any

import paho.mqtt.client as mqtt
import schedule
from apppath import ensure_existence
from warg import ensure_existence
from warg import busy_indicator
from draugr.writers import LogWriter, MockWriter, Writer
from warg import NOD
Expand Down Expand Up @@ -66,20 +76,20 @@ def main(setting_scope: SettingScopeEnum = SettingScopeEnum.user) -> None:
client.on_publish = on_publish
client.on_disconnect = on_disconnect

HEIMDALLR_SETTINGS = HeimdallrSettings(setting_scope)
heimdallr_settings = HeimdallrSettings(setting_scope)

client.username_pw_set(
HEIMDALLR_SETTINGS.mqtt_username, HEIMDALLR_SETTINGS.mqtt_password
heimdallr_settings.mqtt_username, heimdallr_settings.mqtt_password
)
try:
client.connect(
HEIMDALLR_SETTINGS.mqtt_broker, HEIMDALLR_SETTINGS.mqtt_port, keepalive=60
heimdallr_settings.mqtt_broker, heimdallr_settings.mqtt_port, keepalive=60
)
except ValueError as ve:
raise ValueError(
f"{HEIMDALLR_SETTINGS._mqtt_settings_path},"
f"{HEIMDALLR_SETTINGS.mqtt_broker},"
f"{HEIMDALLR_SETTINGS.mqtt_port},"
f"{heimdallr_settings._mqtt_settings_path},"
f"{heimdallr_settings.mqtt_broker},"
f"{heimdallr_settings.mqtt_port},"
f"{ve}"
)

Expand Down
12 changes: 11 additions & 1 deletion heimdallr/entry_points/server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "Christian Heider Nielsen"
__doc__ = r"""
Created on 19/03/2020
"""


import copy
import datetime
import json
Expand All @@ -7,7 +17,7 @@

import dash
import flask
from apppath import ensure_existence
from warg import ensure_existence
from dash import Dash
from dash.dash_table import DataTable
from dash.dependencies import Input, Output
Expand Down
8 changes: 8 additions & 0 deletions heimdallr/server/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "Christian Heider Nielsen"
__doc__ = r"""
Created on 19/03/2020
"""
100 changes: 45 additions & 55 deletions heimdallr/utilities/publisher/system_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,62 @@
Created on 29/03/2020
"""

from typing import Dict, Mapping, Tuple
from typing import Dict, Tuple

import psutil

__all__ = ["get_list_of_process_sorted_by_memory"]


def select(mapping: Mapping, *a) -> Mapping:
"""
Select keys from mapping if in a
Args:
mapping:
*a:
Returns:
"""
return {k: v for k, v in mapping.items() if k in a}
from warg.generators.mapping_generator import select_dict


def get_list_of_process_sorted_by_memory(
attrs: Tuple = ("name", "username"), scaling: float = (1024**2), top_k: int = 10
) -> Dict:
"""
Get list of running process sorted by Memory Usage
"""
list_of_proc_objects = [] # TODO: REFACTOR TO PID,VAL DICT DIRECTLY?
for proc in psutil.process_iter():
try:
proc_info = proc.as_dict(attrs={"pid", *attrs})
proc_info["vms"] = proc.memory_info().vms / scaling
list_of_proc_objects.append(proc_info)
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
sorted_entries = sorted(
list_of_proc_objects, key=lambda proc_obj: proc_obj["vms"], reverse=True
)
if top_k:
sorted_entries = sorted_entries[:top_k]
return {v["pid"]: select(v, "vms", *attrs) for v in sorted_entries}
attrs: Tuple = ("name", "username"), scaling: float = (1024 ** 2), top_k: int = 10
) -> Dict:
"""
Get list of running process sorted by Memory Usage
"""
list_of_proc_objects = [] # TODO: REFACTOR TO PID,VAL DICT DIRECTLY?
for proc in psutil.process_iter():
try:
proc_info = proc.as_dict(attrs = {"pid", *attrs})
proc_info["vms"] = proc.memory_info().vms / scaling
list_of_proc_objects.append(proc_info)
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
sorted_entries = sorted(
list_of_proc_objects, key = lambda proc_obj: proc_obj["vms"], reverse = True
)
if top_k:
sorted_entries = sorted_entries[:top_k]
return {v["pid"]: select_dict(v, "vms", *attrs) for v in sorted_entries}


if __name__ == "__main__":

def main():
"""description"""
print("*** Iterate over all running process and print process ID & Name ***")
for proc in psutil.process_iter():
try:
process_name = proc.name()
process_id = proc.pid
print(process_name, " ::: ", process_id)
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
print("*** Create a list of all running processes ***")
def main():
"""description"""
print("*** Iterate over all running process and print process ID & Name ***")
for proc in psutil.process_iter():
try:
process_name = proc.name()
process_id = proc.pid
print(process_name, " ::: ", process_id)
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
print("*** Create a list of all running processes ***")


def all_info_procs():
"""description"""
list_of_process_names = list()
for proc in psutil.process_iter():
p_info_dict = proc.as_dict()
list_of_process_names.append(p_info_dict)
for elem in list_of_process_names:
print(elem)

def all_info_procs():
"""description"""
list_of_process_names = list()
for proc in psutil.process_iter():
p_info_dict = proc.as_dict()
list_of_process_names.append(p_info_dict)
for elem in list_of_process_names:
print(elem)

# main()
print(get_list_of_process_sorted_by_memory())
# all_info_procs()
# main()
print(get_list_of_process_sorted_by_memory())
# all_info_procs()
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

__all__ = ["disable_service", "remove_service", "install_service", "enable_service"]

from pathlib import Path

from draugr.os_utilities.windows_utilities import (
delete_task,
new_user_logon_execute_task,
Expand Down
2 changes: 1 addition & 1 deletion heimdallr/utilities/server/google_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
except:
print("try upgrade google-api-python-client")

from apppath import ensure_existence
from warg import ensure_existence
from heimdallr.configuration.heimdallr_settings import HeimdallrSettings
from heimdallr.utilities.date_tools import iso_dt_to_datetime

Expand Down
Loading

0 comments on commit 9147ade

Please sign in to comment.