Skip to main content

sam_pytools is a collection of Python utilities that provide commonly used functions, so we do not need to write

Project description

PY Tools

sam_pytools is a collection of Python utilities that provide commonly used functions for handling dates, HTTP requests, JSON manipulation, logging, and more. These tools help streamline various tasks in Python projects.

Installation

pip install samPytools

Available Modules

GlobalValues: Manages global values like home and log directories.
CoreUtils: Contains utility methods for general operations 
like downloading images, decoding bytes, generating unique IDs, etc.
DateUtils: Provides date manipulation functions, 
including time difference calculations and interval additions.
HttpUtils: Offers HTTP helper methods for GET and POST requests.
JsonUtils: Contains JSON helper functions, like converting dictionaries to objects.
LogUtils: Manages logging and error handling.
AsyncUtils: Enables asynchronous execution of given tasks with asyncio or ThreadPoolExecutor.

pip install sam_pytools

Special features

For easier and clean error tracing

LogUtils.getErrorMessage() is the one that can make life easier

Another is AsyncUtils

    from sam_tools import AsyncUtils

      def task1():
          time.sleep(2)
          return 'task1 finished ' + DateUtils.now_str()
      
      def task2(par1):
          time.sleep(3)
          return f'task2 finished {DateUtils.now_str()}, received params => {par1}'
      
      def task3(par1, par2):
          time.sleep(1)
          return f'task3 finished {DateUtils.now_str()}, received params => {par1},{par2}'

      task_list = [(task1, []), (task2, [1]), (task3, [1, 2])]
      #Execute tasks asynchronously
      print(f'Tasks reached at {DateUtils.now_str()}')
      AsyncUtils.execute_tasks_with_no_wait(task_list)
      print(f'Tasks started at {DateUtils.now_str()}')

General about pip

If you want to reset your testing virtual environment

pip freeze | xargs pip uninstall -y

then to install your requirements

pip install -r requirements.txt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sam_pytools-0.1.2.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sam_pytools-0.1.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file sam_pytools-0.1.2.tar.gz.

File metadata

  • Download URL: sam_pytools-0.1.2.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for sam_pytools-0.1.2.tar.gz
Algorithm Hash digest
SHA256 74f42358fa0981df6a88a78c562bf8ccfbbb7dcdde9470653121c997aae30564
MD5 efa97d6c751eafe154e27d81335e1f52
BLAKE2b-256 9919395c7efaad1cd91e7b14004167020c1dbd44b213fcdc8bf73082fc68526b

See more details on using hashes here.

File details

Details for the file sam_pytools-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sam_pytools-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for sam_pytools-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f2c67359df546b31dff491c20f6b9952d2ba91c1b55421ad29d2e3b3de3d34de
MD5 55542e89e77e35b3364a6765d53a13f3
BLAKE2b-256 27b8e6f7adf684f4f941caef0b1d4565cd1d46018bfeb03fedee31a4b66075c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page