Compare commits
No commits in common. "6529fdbdd80c6c4899c53478a5f6c830c92abd4d" and "dfb2b83c067ef63f8dbf51591cbb29e6d150b010" have entirely different histories.
6529fdbdd8
...
dfb2b83c06
|
@ -8,59 +8,64 @@ jobs:
|
||||||
test-lint:
|
test-lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
- run: apt-get -y update && apt-get -y install python3-pip libenchant-2-2 aspell-en
|
||||||
- name: Prepare image
|
- run: pip3 install .[full] .[dev]
|
||||||
run: apt-get -y update && apt-get -y install python3-pip libenchant-2-2 aspell-en
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pip3 install .[full] .[dev]
|
|
||||||
- run: isort --check-only --diff .
|
- run: isort --check-only --diff .
|
||||||
- run: pylint morss --rcfile=.pylintrc --disable=C,R,W --fail-under=8
|
- run: pylint morss --rcfile=.pylintrc --disable=C,R,W --fail-under=8
|
||||||
- run: pytest --cov=morss tests
|
- run: pytest --cov=morss tests
|
||||||
|
|
||||||
python-publish:
|
|
||||||
|
publish-deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
- run: apt-get -y update && apt-get -y install python3-pip python3-build
|
||||||
- name: Prepare image
|
- run: python3 -m build
|
||||||
run: apt-get -y update && apt-get -y install python3-pip python3-build
|
|
||||||
|
|
||||||
- name: Build package
|
|
||||||
run: python3 -m build
|
|
||||||
|
|
||||||
- name: Publish package
|
- name: Publish package
|
||||||
uses: https://github.com/pypa/gh-action-pypi-publish@release/v1
|
uses: https://github.com/pypa/gh-action-pypi-publish@release/v1
|
||||||
with:
|
with:
|
||||||
password: ${{ secrets.pypi_api_token }}
|
password: ${{ secrets.pypi_api_token }}
|
||||||
|
- name: Push python package to the server
|
||||||
|
uses: https://github.com/appleboy/scp-action@v0.1.4
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.ssh_host }}
|
||||||
|
username: ${{ secrets.ssh_user }}
|
||||||
|
key: ${{ secrets.ssh_key }}
|
||||||
|
source: dist/morss-*.tar.gz
|
||||||
|
target: /home/ubuntu
|
||||||
|
- name: Install & reload the server
|
||||||
|
uses: https://github.com/appleboy/ssh-action@v0.1.10
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.ssh_host }}
|
||||||
|
username: ${{ secrets.ssh_user }}
|
||||||
|
key: ${{ secrets.ssh_key }}
|
||||||
|
script: |
|
||||||
|
sudo pip install --upgrade dist/morss*-.tar.gz[full]
|
||||||
|
sudo rm -r dist
|
||||||
|
sudo morss-helper reload
|
||||||
|
|
||||||
docker-publish-deploy:
|
docker-publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: https://github.com/docker/setup-qemu-action@v2
|
uses: https://github.com/docker/setup-qemu-action@v2
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: https://github.com/docker/setup-buildx-action@v2
|
uses: https://github.com/docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: https://github.com/docker/login-action@v2
|
uses: https://github.com/docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.docker_user }}
|
username: ${{ secrets.docker_user }}
|
||||||
password: ${{ secrets.docker_pwd }}
|
password: ${{ secrets.docker_pwd }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: https://github.com/docker/build-push-action@v4
|
uses: https://github.com/docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
|
@ -68,11 +73,3 @@ jobs:
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.docker_repo }}
|
tags: ${{ secrets.docker_repo }}
|
||||||
|
|
||||||
- name: Deploy on server
|
|
||||||
uses: https://github.com/appleboy/ssh-action@v0.1.10
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.ssh_host }}
|
|
||||||
username: ${{ secrets.ssh_user }}
|
|
||||||
key: ${{ secrets.ssh_key }}
|
|
||||||
script: morss-update
|
|
||||||
|
|
11
README.md
11
README.md
|
@ -81,9 +81,9 @@ From git
|
||||||
pip install git+https://git.pictuga.com/pictuga/morss.git#egg=morss[full]
|
pip install git+https://git.pictuga.com/pictuga/morss.git#egg=morss[full]
|
||||||
```
|
```
|
||||||
|
|
||||||
The full install includes all the cache backends. Otherwise, only in-memory
|
The full install includes all the cache backends. Otherwise, only in-memory and
|
||||||
cache is available. The full install also includes gunicorn (for more efficient
|
sqlite3 caches are available. The full install also includes gunicorn (for more
|
||||||
HTTP handling).
|
efficient HTTP handling).
|
||||||
|
|
||||||
The dependency `lxml` is fairly long to install (especially on Raspberry Pi, as
|
The dependency `lxml` is fairly long to install (especially on Raspberry Pi, as
|
||||||
C code needs to be compiled). If possible on your distribution, try installing
|
C code needs to be compiled). If possible on your distribution, try installing
|
||||||
|
@ -353,7 +353,7 @@ Using cache and passing arguments:
|
||||||
```python
|
```python
|
||||||
>>> import morss
|
>>> import morss
|
||||||
>>> url = 'http://feeds.bbci.co.uk/news/rss.xml'
|
>>> url = 'http://feeds.bbci.co.uk/news/rss.xml'
|
||||||
>>> cache = '/tmp/morss-cache' # diskcache cache location
|
>>> cache = '/tmp/morss-cache.db' # sqlite cache location
|
||||||
>>> options = {'csv':True}
|
>>> options = {'csv':True}
|
||||||
>>> xml_string = morss.process(url, cache, options)
|
>>> xml_string = morss.process(url, cache, options)
|
||||||
>>> xml_string[:50]
|
>>> xml_string[:50]
|
||||||
|
@ -367,10 +367,11 @@ under the hood.
|
||||||
Doing it step-by-step:
|
Doing it step-by-step:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import morss
|
import morss, morss.crawler
|
||||||
|
|
||||||
url = 'http://newspaper.example/feed.xml'
|
url = 'http://newspaper.example/feed.xml'
|
||||||
options = morss.Options(csv=True) # arguments
|
options = morss.Options(csv=True) # arguments
|
||||||
|
morss.crawler.sqlite_default = '/tmp/morss-cache.db' # sqlite cache location
|
||||||
|
|
||||||
url, rss = morss.FeedFetch(url, options) # this only grabs the RSS feed
|
url, rss = morss.FeedFetch(url, options) # this only grabs the RSS feed
|
||||||
rss = morss.FeedGather(rss, url, options) # this fills the feed and cleans it up
|
rss = morss.FeedGather(rss, url, options) # this fills the feed and cleans it up
|
||||||
|
|
|
@ -104,7 +104,20 @@ class DiskCacheHandler(BaseCache):
|
||||||
|
|
||||||
|
|
||||||
if 'CACHE' in os.environ:
|
if 'CACHE' in os.environ:
|
||||||
if os.environ['CACHE'] == 'redis':
|
if os.environ['CACHE'] == 'mysql':
|
||||||
|
default_cache = MySQLCacheHandler(
|
||||||
|
user = os.getenv('MYSQL_USER'),
|
||||||
|
password = os.getenv('MYSQL_PWD'),
|
||||||
|
database = os.getenv('MYSQL_DB'),
|
||||||
|
host = os.getenv('MYSQL_HOST', 'localhost')
|
||||||
|
)
|
||||||
|
|
||||||
|
elif os.environ['CACHE'] == 'sqlite':
|
||||||
|
default_cache = SQLiteCache(
|
||||||
|
os.getenv('SQLITE_PATH', ':memory:')
|
||||||
|
)
|
||||||
|
|
||||||
|
elif os.environ['CACHE'] == 'redis':
|
||||||
default_cache = RedisCacheHandler(
|
default_cache = RedisCacheHandler(
|
||||||
host = os.getenv('REDIS_HOST', 'localhost'),
|
host = os.getenv('REDIS_HOST', 'localhost'),
|
||||||
port = int(os.getenv('REDIS_PORT', 6379)),
|
port = int(os.getenv('REDIS_PORT', 6379)),
|
||||||
|
|
|
@ -428,7 +428,7 @@ def process(url, cache=None, options=None):
|
||||||
options = Options(options)
|
options = Options(options)
|
||||||
|
|
||||||
if cache:
|
if cache:
|
||||||
caching.default_cache = caching.DiskCacheHandler(cache)
|
caching.default_cache = caching.SQLiteCache(cache)
|
||||||
|
|
||||||
url, rss = FeedFetch(url, options)
|
url, rss = FeedFetch(url, options)
|
||||||
rss = FeedGather(rss, url, options)
|
rss = FeedGather(rss, url, options)
|
||||||
|
|
Loading…
Reference in New Issue