From 75a8a6eee4bffada10ac42f3c16b446263047856 Mon Sep 17 00:00:00 2001 From: desbma Date: Sun, 30 Nov 2014 17:41:43 +0100 Subject: [PATCH] Reorganize files for setuptools packaging --- MANIFEST.in | 1 + README.md | 24 +++++++---- .../__init__.py | 21 ++++++---- bin_dep.py => hddfancontrol/bin_dep.py | 0 .../colored_logging.py | 0 requirements.txt | 2 +- setup.py | 41 +++++++++++++++++++ 7 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 MANIFEST.in rename hdd_fancontrol.py => hddfancontrol/__init__.py (99%) rename bin_dep.py => hddfancontrol/bin_dep.py (100%) rename colored_logging.py => hddfancontrol/colored_logging.py (100%) create mode 100755 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..a62182e --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include LICENSE README.md requirements.txt diff --git a/README.md b/README.md index 379f8a9..65c9c20 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,20 @@ Most motherboards and SATA drives fit these requirements. ## Installation -HDD Fan control needs Python >= 3.4. It probably works with Python 3.3 with minimum efforts, or even previous 3.x versions, but I have not tested it. +**HDD Fan control needs Python >= 3.4.** -1. Clone this repository -2. If you don't have it, [install pip](http://www.pip-installer.org/en/latest/installing.html) for Python3 (may not be needed with Python >= 3.4). -On Ubuntu and other Debian derivatives, you can install with `sudo apt-get install python3-pip` -3. Install Python dependencies: `pip3 install -r requirements.txt` +### From PyPI (with PIP) + +1. If you don't already have it, [install pip](http://www.pip-installer.org/en/latest/installing.html) for Python 3 (not needed if you are using Python >= 3.4) +2. Install HDD Fan control: `pip3 install hddfancontrol` +3. Install [hdparm](http://sourceforge.net/projects/hdparm/) and [hddtemp](http://www.guzu.net/linux/hddtemp.php). +On Ubuntu and other Debian derivatives: `sudo apt-get install hdparm hddtemp`. + +### From source + +1. If you don't already have it, [install setuptools](https://pypi.python.org/pypi/setuptools#installation-instructions) for Python 3 +2. Clone this repository: `git clone https://github.com/desbma/hddfancontrol` +3. Install HDD Fan control: `python3 setup.py install` 4. Install [hdparm](http://sourceforge.net/projects/hdparm/) and [hddtemp](http://www.guzu.net/linux/hddtemp.php). On Ubuntu and other Debian derivatives: `sudo apt-get install hdparm hddtemp`. @@ -92,7 +100,7 @@ Some Hitachi (now HGST) drives support a special way of querying temperature tha ## Command line usage -Run `./hdd_fancontrol.py -h` to get full command line reference. +Run `hddfancontrol -h` to get full command line reference. As an example, the command line below will instruct HDD Fan control to: @@ -105,9 +113,9 @@ As an example, the command line below will instruct HDD Fan control to: * monitor drive activity using special files `/sys/block/sda/stat` and `/sys/block/sdb/stat` * automatically spin down drives if they are inactive for 2 hours (7200 seconds) * run in daemon mode -* log what is going on to `/var/log/hdd_fancontrol.log` +* log what is going on to `/var/log/hddfancontrol.log` -`./hdd_fancontrol.py -d /dev/sda /dev/sdb -p /sys/class/hwmon/hwmon1/device/pwm2 /sys/class/hwmon/hwmon1/device/pwm3 --pwm-start-value 200 200 --pwm-stop-value 75 75 --min-fan-speed-prct 10 -i 60 --stat-files /sys/block/sda/stat /sys/block/sdb/stat --spin-down-time 7200 -b -l /var/log/hdd_fancontrol.log` +`hddfancontrol -d /dev/sda /dev/sdb -p /sys/class/hwmon/hwmon1/device/pwm2 /sys/class/hwmon/hwmon1/device/pwm3 --pwm-start-value 200 200 --pwm-stop-value 75 75 --min-fan-speed-prct 10 -i 60 --stat-files /sys/block/sda/stat /sys/block/sdb/stat --spin-down-time 7200 -b -l /var/log/hddfancontrol.log` ## License diff --git a/hdd_fancontrol.py b/hddfancontrol/__init__.py similarity index 99% rename from hdd_fancontrol.py rename to hddfancontrol/__init__.py index e9a0fc3..cf26728 100755 --- a/hdd_fancontrol.py +++ b/hddfancontrol/__init__.py @@ -21,8 +21,8 @@ import time import daemon import daemon.pidlockfile -import bin_dep -import colored_logging +from . import bin_dep +from . import colored_logging exit_evt = threading.Event() @@ -489,13 +489,10 @@ def main(drive_filepaths, fan_pwm_filepaths, fan_start_values, fan_stop_values, logger.error(e) -# check deps -bin_dep.check_bin_dependency(("hddtemp", "hdparm")) - - -if __name__ == "__main__": +def cl_main(): # parse args - arg_parser = argparse.ArgumentParser(description=__doc__) + arg_parser = argparse.ArgumentParser(description=__doc__, + formatter_class=argparse.ArgumentDefaultsHelpFormatter) arg_parser.add_argument("-d", "--drives", required=True, @@ -647,3 +644,11 @@ if __name__ == "__main__": args.interval_s, args.spin_down_time_s, args.stat_filepaths) + + +# check deps +bin_dep.check_bin_dependency(("hddtemp", "hdparm")) + + +if __name__ == "__main__": + cl_main() diff --git a/bin_dep.py b/hddfancontrol/bin_dep.py similarity index 100% rename from bin_dep.py rename to hddfancontrol/bin_dep.py diff --git a/colored_logging.py b/hddfancontrol/colored_logging.py similarity index 100% rename from colored_logging.py rename to hddfancontrol/colored_logging.py diff --git a/requirements.txt b/requirements.txt index 89f0e20..9f6ff4a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ --e git+https://github.com/Yuego/python-daemon@1.5.5#egg=python-daemon-py3k +python-daemon-3K>=1.5.8 diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..46dc828 --- /dev/null +++ b/setup.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from setuptools import find_packages, setup + +VERSION = "1.0.0" + + +with open("requirements.txt", "rt") as f: + requirements = f.read().splitlines() + +with open("README.md", "rt") as f: + readme = f.read() + +setup(name="hddfancontrol", + version=VERSION, + author="desbma", + packages=find_packages(), + entry_points={"console_scripts": ["hddfancontrol = hddfancontrol:cl_main"]}, + install_requires=requirements, + description="Control system fan speed by monitoring hard drive temperature", + long_description=readme, + url="https://github.com/desbma/hddfancontrol", + download_url="https://github.com/desbma/hddfancontrol/archive/%s.tar.gz" % (VERSION), + keywords=["hdd", "drive", "temperature", "fan", "control", "speed"], + classifiers=["Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Environment :: No Input/Output (Daemon)", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.3", + "Programming Language :: Python :: 3.4", + "Topic :: System :: Hardware", + "Topic :: System :: Monitoring", + "Topic :: Utilities"])