whatamithinking-services


Namewhatamithinking-services JSON
Version 1.1.2 PyPI version JSON
download
home_pageNone
Summarycross platform service or daemon framework
upload_time2025-08-17 22:12:11
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseNone
keywords daemon service
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # WhatAmIThinking-Services

Cross-platform service library for building platform services that integrate with platform tooling and can be installed/started/stopped/uninstalled from the command line.

## Table of Contents

<!-- TOC -->

- [WhatAmIThinking-Services](#whatamithinking-services)
  - [Table of Contents](#table-of-contents)
  - [Code Usage](#code-usage)
  - [CLI](#cli)
    - [Main](#main)
    - [Install Subcommand](#install-subcommand)
    - [Uninstall Subcommand](#uninstall-subcommand)
    - [Start Subcommand](#start-subcommand)
    - [Stop Subcommand](#stop-subcommand)
  - [Platforms](#platforms)
    - [Windows](#windows)

<!-- /TOC -->

## Code Usage

You should subclass `PlatformService` and override the following methods:

-   `run`: put your core blocking logic for running your service here
    -   call `self.started()` just before you start blocking in this method to signal to the platform that your service has started
    -   call `self.stopped()` just before this returns to signal to the platform your service has stopped
-   `stop`: send signal to stop your service and wait for it to be stopped.

```python
import time
import threading

from whatamithinking.services import PlatformService


class MyService(PlatformService):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._event = threading.Event()
        self._exited = threading.Event()

    def run(self):
        self.started()
        self._event.wait()
        self._exited.set()
        self.stopped()

    def stop(self):
        self._event.set()
        self._exited.wait()


if __name__ == '__main__':
    # this will handle commandline params and run your service
    MyService.execute()
```

## CLI

A CLI is included in the service class `execute` method, so you can perform operations such as `install`, `uninstall`, etc.
The following is an example showing the CLI.

### Main

```
usage: My Service [-h] {install,uninstall,start,stop} ...

Description of my service

options:
  -h, --help            show this help message and exit

subcommand:
  {install,uninstall,start,stop}
```

### Install Subcommand

```
usage: My Service install [-h] [--username USERNAME] [--password PASSWORD]

install the service on this machine

options:
  -h, --help           show this help message and exit
  --username USERNAME  domain\username of the account to run the service under
  --password PASSWORD  password of the account to run the service under
```

### Uninstall Subcommand

```
usage: My Service uninstall [-h]

uninstall the service from the machine

options:
  -h, --help  show this help message and exit
```

### Start Subcommand

```
usage: My Service start [-h]

start the service if it is installed or throw error if not

options:
  -h, --help  show this help message and exit
```

### Stop Subcommand

```
usage: My Service stop [-h]

stop the service if it is installed or throw error if not

options:
  -h, --help  show this help message and exit
```

## Platforms

### Windows

NOTE: obscure bug was found when trying to run installer to update
and event viewer was open at same time. servicemanager.pyd file becomes locked up.
turns out event viewer does this. closing event viewer removes this lock.
see: https://mail.python.org/pipermail/python-win32/2004-December/002736.html

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "whatamithinking-services",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "daemon, service",
    "author": null,
    "author_email": "connormaynes@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/72/2a/45587860fecdcf685dea8e10ff2a35ecb573fd029141a66322e536af1318/whatamithinking_services-1.1.2.tar.gz",
    "platform": null,
    "description": "# WhatAmIThinking-Services\n\nCross-platform service library for building platform services that integrate with platform tooling and can be installed/started/stopped/uninstalled from the command line.\n\n## Table of Contents\n\n<!-- TOC -->\n\n- [WhatAmIThinking-Services](#whatamithinking-services)\n  - [Table of Contents](#table-of-contents)\n  - [Code Usage](#code-usage)\n  - [CLI](#cli)\n    - [Main](#main)\n    - [Install Subcommand](#install-subcommand)\n    - [Uninstall Subcommand](#uninstall-subcommand)\n    - [Start Subcommand](#start-subcommand)\n    - [Stop Subcommand](#stop-subcommand)\n  - [Platforms](#platforms)\n    - [Windows](#windows)\n\n<!-- /TOC -->\n\n## Code Usage\n\nYou should subclass `PlatformService` and override the following methods:\n\n-   `run`: put your core blocking logic for running your service here\n    -   call `self.started()` just before you start blocking in this method to signal to the platform that your service has started\n    -   call `self.stopped()` just before this returns to signal to the platform your service has stopped\n-   `stop`: send signal to stop your service and wait for it to be stopped.\n\n```python\nimport time\nimport threading\n\nfrom whatamithinking.services import PlatformService\n\n\nclass MyService(PlatformService):\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._event = threading.Event()\n        self._exited = threading.Event()\n\n    def run(self):\n        self.started()\n        self._event.wait()\n        self._exited.set()\n        self.stopped()\n\n    def stop(self):\n        self._event.set()\n        self._exited.wait()\n\n\nif __name__ == '__main__':\n    # this will handle commandline params and run your service\n    MyService.execute()\n```\n\n## CLI\n\nA CLI is included in the service class `execute` method, so you can perform operations such as `install`, `uninstall`, etc.\nThe following is an example showing the CLI.\n\n### Main\n\n```\nusage: My Service [-h] {install,uninstall,start,stop} ...\n\nDescription of my service\n\noptions:\n  -h, --help            show this help message and exit\n\nsubcommand:\n  {install,uninstall,start,stop}\n```\n\n### Install Subcommand\n\n```\nusage: My Service install [-h] [--username USERNAME] [--password PASSWORD]\n\ninstall the service on this machine\n\noptions:\n  -h, --help           show this help message and exit\n  --username USERNAME  domain\\username of the account to run the service under\n  --password PASSWORD  password of the account to run the service under\n```\n\n### Uninstall Subcommand\n\n```\nusage: My Service uninstall [-h]\n\nuninstall the service from the machine\n\noptions:\n  -h, --help  show this help message and exit\n```\n\n### Start Subcommand\n\n```\nusage: My Service start [-h]\n\nstart the service if it is installed or throw error if not\n\noptions:\n  -h, --help  show this help message and exit\n```\n\n### Stop Subcommand\n\n```\nusage: My Service stop [-h]\n\nstop the service if it is installed or throw error if not\n\noptions:\n  -h, --help  show this help message and exit\n```\n\n## Platforms\n\n### Windows\n\nNOTE: obscure bug was found when trying to run installer to update\nand event viewer was open at same time. servicemanager.pyd file becomes locked up.\nturns out event viewer does this. closing event viewer removes this lock.\nsee: https://mail.python.org/pipermail/python-win32/2004-December/002736.html\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "cross platform service or daemon framework",
    "version": "1.1.2",
    "project_urls": {
        "Documentation": "https://github.com/whatamithinking/services",
        "Homepage": "https://github.com/whatamithinking/services",
        "Issues": "https://github.com/whatamithinking/services/issues",
        "Repository": "https://github.com/whatamithinking/services"
    },
    "split_keywords": [
        "daemon",
        " service"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6818950d916d8f1e9927fd363fb22d18a13f89550eacd3bab6f9e5cc35638430",
                "md5": "19e11c49c308151a1470cf45431a3342",
                "sha256": "ffcc20f03bf318e9623ebfac0a63a4b4467dfa3fa9ad2fbefbf0e77c532d7c9b"
            },
            "downloads": -1,
            "filename": "whatamithinking_services-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "19e11c49c308151a1470cf45431a3342",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 5402,
            "upload_time": "2025-08-17T22:12:09",
            "upload_time_iso_8601": "2025-08-17T22:12:09.915440Z",
            "url": "https://files.pythonhosted.org/packages/68/18/950d916d8f1e9927fd363fb22d18a13f89550eacd3bab6f9e5cc35638430/whatamithinking_services-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "722a45587860fecdcf685dea8e10ff2a35ecb573fd029141a66322e536af1318",
                "md5": "530d2cc550de95f1450382514b87c2d1",
                "sha256": "6b61f57718436a575f08676aa53c4fc523f3529c7942677fe29e26a9cacd3eea"
            },
            "downloads": -1,
            "filename": "whatamithinking_services-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "530d2cc550de95f1450382514b87c2d1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 5874,
            "upload_time": "2025-08-17T22:12:11",
            "upload_time_iso_8601": "2025-08-17T22:12:11.476481Z",
            "url": "https://files.pythonhosted.org/packages/72/2a/45587860fecdcf685dea8e10ff2a35ecb573fd029141a66322e536af1318/whatamithinking_services-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-17 22:12:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "whatamithinking",
    "github_project": "services",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "whatamithinking-services"
}
        
Elapsed time: 1.58992s