Setting up pypi
- First update the software:
sudo apt update sudo apt upgrade sudo apt install python3-pip pip install setuptools pip install twine - Copy git/hooks/pre-push to .git/hooks
cp git/hooks/pre-push .git/hooks - Get an api token from https://pypi.org/manage/account/token/
- create/edit the ~/.pypirc file:
[distutils] index-servers = pypi thompcoutils [pypi] username = __token__ password = <TOKEN FROM https://pypi.org/manage/account/token/> [thompcoutils] repository = https://upload.pypi.org/legacy/ username = __token__ password = <TOKEN FROM https://pypi.org/manage/account/token/>
logging_utils
logging consists of the following classes and functions to help with the burden of logging
RelativePathRotatingFileHandler
Not sure if this is working properly
get_logger()
This function retrieves a logger for your file and function/method. This should be called first. For example:
start_function(logger, **kwargs)
This function tags the log file with the entry of a function/method. You may turn it on or off in your logging configuration note that the msg= argument is reserved for single string messages
end_function(logger, **kwargs)
This function tags the log file with the exit of a function/method. You may turn it on or off in your logging configuration note that the msg= argument is reserved for single string messages
Here is an example of everything
val1 = 5
val2 = 6
logger = get_logger()
start_function(logger, msg="testing")
# or you can call it this way:
start_function(logger, val1=val1, val2=val2)
val1 = 10
val2 = {"first": 1, "second": 2}
end_function(logger, val1=val1, val2=val2)
os_utils
os consists of the following classes and functions
UnhandledOs
This is raised when the library does not recognize the operating system
list_timezones()
This function returns all known timezones
get_timezone()
This function returns the timezone selected by the operating system
kill_process(name)
This function kills the specified process name
is_running(name)
This function returns whether the specified process name is currently running
os_type()
This function returns the operating system type
get_ip_addresses()
This function returns all IP addresses on this hardware
#config This contains the object ConfigUtils It is used to read and write .ini files. You should put all information into the different methods to fully define the configuration file.
The constructor takes the configuration file name, a title to add to the top of the file, and a flag indicating the file is being constructed.
class ConfigManager:
def __init__(self, file_name, title=None, create=False):
The read_entry function reads a section/entry from the file. It takes a default value in case the value does not exist in the file and also to create a new file. The notes parameter describe the entry in the file
def read_entry(self, section, entry, default_value, notes=None):
The read_section function reads the entire section from the configuration file and returns a dictionary of the entries. Note that the notes are only applied to the setion (not to the individual entries)
def read_section(self, section, default_entries, notes=None):
The write function writes a new configuration file. If this is called, the package will check if the file exists. If it does, it will abort with a warning. If the file does not exist, it will write it and abort.
def write(self, out_file):
Here is an example of ConfigManager and its functions:
write = False # set this to True to create the configuration file
cfg_mgr = ConfigManager("test.ini", "This is the title of the ini file\n"
"You can have multiple lines if you use line breaks", write)
first = cfg_mgr.read_entry("User 1", "first name", "Joe", "This is the first name")
last = cfg_mgr.read_entry("User 1", "last name", "Brown", "This is the last name")
age = cfg_mgr.read_entry("User 1", "age", 12)
is_male = cfg_mgr.read_entry("User 1", "male", True)
weight = cfg_mgr.read_entry("User 1", "weight", 23.5)
section = cfg_mgr.read_section("user 2", {"first name": "Sally",
"last name": "Jones",
"age": 15,
"is_male": False,
"weight": 41.3},
"You only get to add notes at the top of the section using this method")
Metadata
Release files for thompcoutils 2.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| thompcoutils-2.2.5.tar.gz | 46.8 kB | Without provenance | Details for thompcoutils-2.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| thompcoutils-2.2.5-py3-none-any.whl | Python 3 | none | any | Details for thompcoutils-2.2.5-py3-none-any.whl |
Total release size: 100.4 kB
Release files / thompcoutils-2.2.5.tar.gz
| Download URL | thompcoutils-2.2.5.tar.gz |
|---|---|
| Size | 46.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
492ae12e9552c5928cc0a3164b26b52d67f85ffd4a81f1f64220d7eadb5654f7
|
|
BLAKE2b-256 checksum How to use checksums |
24e39c588b324af81cd8d9040d09893e729e6d431d2a83a158d9c3cd4ba0841d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / thompcoutils-2.2.5-py3-none-any.whl
| Download URL | thompcoutils-2.2.5-py3-none-any.whl |
|---|---|
| Size | 53.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
00239ac6e9480c0bc81cd9f9ae755ad26ce07978b843f7725fcff7caa35bbfb9
|
|
BLAKE2b-256 checksum How to use checksums |
ddbbffa82a5c4c71907545008a38848094dea56802e2ff73809fe287667092ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for thompcoutils 2.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.