comfortable-swipe/comfortable_swipe/status.py
Rico Tiongson 8464084f56
Package comfortable-swipe with Python (#58)
* Add initial python setup script

* Add working initial python porting definition for comfortable-swipe

* Add python extensions to cpp libraries

* Remove boost and prefer vanilla Python.h implementation

* Add main driver function for comfortable_swipe

* Fix compilation for Python 3

* Remove depcreacted cpp scripts in root

* Move script to entrypoint

* Increment version to beta

* Update variable formatting

* Remove deprecated install script

* Move install to post-install command

* Create install script hooks

* Fix bdist_wheel class errors

* Use absolute path for c++ sources

* Unignore index files

* Move autostart to python

* Allow comfortable swipe autostart for possible virtualenv

* Completely port autostart to python

* Move status to python

* Optimize swipe function

* Remove iostream optimization from buffer

* Register pre-install and post-install in a stack

* Remove underscores from value-defined macros

* Compress default config

* Change cpp to __init__.py

* Error message

* Bugfix for python2
2019-03-04 12:45:09 +08:00

23 lines
659 B
Python

from __future__ import print_function
import os
from comfortable_swipe import autostart
from comfortable_swipe.cpp import service
from comfortable_swipe.constants import NAME, exe
def print_status():
service.status()
print('autostart is', autostart.get_status().upper())
print('{} program is {}'.format(NAME, 'RUNNING' if is_running() else 'STOPPED'))
def is_running():
import psutil
for process in psutil.process_iter():
process_args = [process.name()] + process.cmdline()
for index in range(len(process_args) - 1):
if process_args[index + 1] == 'start' and process_args[index].endswith(NAME):
return True
return False