make php executable path configurable
This commit is contained in:
Родитель
fb31fc43f7
Коммит
79068d3fea
|
@ -1,11 +1,11 @@
|
|||
sudo: false
|
||||
language: python
|
||||
python:
|
||||
- "3.4"
|
||||
- "3.5"
|
||||
- "3.6"
|
||||
|
||||
before_install:
|
||||
- pip install pep8 mypy-lang
|
||||
- pip install pycodestyle mypy
|
||||
|
||||
script:
|
||||
- make test
|
|
@ -3,6 +3,17 @@
|
|||
Changelog
|
||||
---------
|
||||
|
||||
10.0.0
|
||||
+++++
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
* Require Python 3.5 or greater
|
||||
|
||||
**Improvements**
|
||||
|
||||
- Added option to specify PHP binary path
|
||||
|
||||
9.0.1
|
||||
+++++
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -30,7 +30,7 @@ pypi: clean
|
|||
|
||||
.PHONY: test
|
||||
test:
|
||||
pep8 .
|
||||
pycodestyle nextcloud_news_updater
|
||||
python3 -m nextcloud_news_updater --version
|
||||
python3 -m unittest
|
||||
#uncomment once mypy works properly
|
||||
|
|
19
README.rst
19
README.rst
|
@ -26,8 +26,7 @@ console based update API.
|
|||
Dependencies
|
||||
------------
|
||||
|
||||
* **Python >=3.4**
|
||||
* **typing** (from pip) if you are running Python 3.4
|
||||
* **Python >=3.5**
|
||||
|
||||
Pre-Installation
|
||||
----------------
|
||||
|
@ -116,16 +115,16 @@ You can view all options by running::
|
|||
|
||||
::
|
||||
|
||||
usage: nextcloud-news-updater [-h] [--threads THREADS] [--timeout TIMEOUT]
|
||||
usage: __main__.py [-h] [--threads THREADS] [--timeout TIMEOUT]
|
||||
[--interval INTERVAL] [--apilevel {v1-2,v2}]
|
||||
[--loglevel {info,error}] [--config CONFIG]
|
||||
[--phpini PHPINI] [--user USER] [--password PASSWORD]
|
||||
[--version] [--mode {endless,singlerun}]
|
||||
[--version] [--mode {endless,singlerun}] [--php PHP]
|
||||
[url]
|
||||
|
||||
positional arguments:
|
||||
url The URL or absolute path to the directory where
|
||||
nextcloud is installed. Must be specified on the
|
||||
Nextcloud is installed. Must be specified on the
|
||||
command line or in the config file. If the URL starts
|
||||
with http:// or https://, a user and password are
|
||||
required. Otherwise the updater tries to use the
|
||||
|
@ -156,9 +155,9 @@ You can view all options by running::
|
|||
Custom absolute path to the php.ini file to use for
|
||||
the command line updater. If omitted, the default one
|
||||
will be used
|
||||
--user USER, -u USER Admin username to log into Nextcloud. Must be specified
|
||||
on the command line or in the config file if the
|
||||
updater should update over HTTP
|
||||
--user USER, -u USER Admin username to log into Nextcloud. Must be
|
||||
specified on the command line or in the config file if
|
||||
the updater should update over HTTP
|
||||
--password PASSWORD, -p PASSWORD
|
||||
Admin password to log into Nextcloud if the updater
|
||||
should update over HTTP
|
||||
|
@ -167,6 +166,8 @@ You can view all options by running::
|
|||
Mode to run the updater in: endless runs the update
|
||||
again after the specified interval, singlerun only
|
||||
executes the update once
|
||||
--php PHP Path to the PHP binary, e.g. /usr/bin/php7.0, defaults
|
||||
to php
|
||||
|
||||
|
||||
|
||||
|
@ -189,6 +190,8 @@ You can also put your settings in a config file, looking like this:
|
|||
# or v2 which is currently a draft
|
||||
apilevel = v1-2
|
||||
mode = endless
|
||||
# path to php binary
|
||||
php = /usr/bin/php7.0
|
||||
|
||||
**Note**: You can omit options in the config file if you want to use the defaults, but you can not have more than the allowed parameters present, otherwise an exception will abort the updater.
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class CliApi(Api):
|
|||
if not directory.endswith('/'):
|
||||
directory += '/'
|
||||
self.directory = directory
|
||||
base_command = ['php', '-f', self.directory + 'occ']
|
||||
base_command = [config.php, '-f', self.directory + 'occ']
|
||||
if phpini is not None and phpini.strip() != '':
|
||||
base_command += ['-c', phpini]
|
||||
self.before_cleanup_command = base_command + [
|
||||
|
|
|
@ -59,6 +59,10 @@ class ArgumentParser:
|
|||
'specified interval, singlerun only '
|
||||
'executes the update once',
|
||||
choices=['endless', 'singlerun'])
|
||||
self.parser.add_argument('--php',
|
||||
help='Path to the PHP binary, '
|
||||
'e.g. /usr/bin/php7.0, defaults to '
|
||||
'php', default='php')
|
||||
self.parser.add_argument('url',
|
||||
help='The URL or absolute path to the '
|
||||
'directory where Nextcloud is installed.'
|
||||
|
|
|
@ -36,6 +36,7 @@ class Config:
|
|||
'mode': Types.string,
|
||||
'threads': Types.integer,
|
||||
'interval': Types.integer,
|
||||
'php': Types.string,
|
||||
}
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
@ -45,6 +46,7 @@ class Config:
|
|||
self.apilevel = 'v1-2'
|
||||
self.threads = 10
|
||||
self.mode = 'endless'
|
||||
self.php = 'php'
|
||||
self.password = ''
|
||||
self.user = None # type: Optional[str]
|
||||
self.url = None # type: Optional[str]
|
||||
|
|
11
setup.py
11
setup.py
|
@ -2,14 +2,9 @@ from platform import python_version
|
|||
from sys import exit, version_info
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
if version_info < (3, 4):
|
||||
print('Error: Python 3.4 required but found %s' % python_version())
|
||||
exit(1)
|
||||
|
||||
if version_info < (3, 5):
|
||||
install_requires = ['typing']
|
||||
else:
|
||||
install_requires = []
|
||||
print('Error: Python 3.5 required but found %s' % python_version())
|
||||
exit(1)
|
||||
|
||||
with open('README.rst', 'r') as infile:
|
||||
long_description = infile.read()
|
||||
|
@ -30,7 +25,7 @@ setup(
|
|||
include_package_data=True,
|
||||
license='GPL',
|
||||
keywords=['nextcloud', 'news', 'updater', 'RSS', 'Atom', 'feed', 'reader'],
|
||||
install_requires=install_requires,
|
||||
install_requires=[],
|
||||
classifiers=[
|
||||
'Intended Audience :: System Administrators',
|
||||
'Environment :: Console',
|
||||
|
|
|
@ -7,4 +7,5 @@ loglevel = info
|
|||
url = /
|
||||
phpini = /path/to/custom/php.ini
|
||||
apilevel = v2
|
||||
mode = singlerun
|
||||
mode = singlerun
|
||||
php = /usr/local/bin/php7.0
|
|
@ -38,6 +38,7 @@ class TestConfig(TestCase):
|
|||
self.assertEqual(config.phpini, '/path/to/custom/php.ini')
|
||||
self.assertEqual(config.apilevel, 'v2')
|
||||
self.assertEqual(config.mode, 'singlerun')
|
||||
self.assertEqual(config.php, '/usr/local/bin/php7.0')
|
||||
|
||||
def test_parse_defaults(self):
|
||||
config = self.parser.parse_file(find_test_config('empty.ini'))
|
||||
|
|
Загрузка…
Ссылка в новой задаче