Skip to content

Commit

Permalink
Merge pull request #4 from MarekSuchanek/task03
Browse files Browse the repository at this point in the history
Task03
  • Loading branch information
MarekSuchanek authored Oct 22, 2016
2 parents 2e7b734 + 6d23368 commit 858eda8
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 32 deletions.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include LICENSE
include README.md
include config/auth.example.cfg
1 change: 1 addition & 0 deletions README
86 changes: 63 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Twitter Wall

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
![Version](https://img.shields.io/badge/release-v0.2-orange.svg)
![Version](https://img.shields.io/badge/release-v0.3-orange.svg)


Twitter Wall is simple [Python](https://www.python.org) powered app for
Expand All @@ -25,20 +25,60 @@ equivalents):
#### System-wide environment:

```
../PYT-TwitterWall/ $ python3 -m pip -r requirements.txt
../PYT-TwitterWall/ $ python3 twitterwall ...
$ python3 setup.py install
$ twitterwall ...
```

#### Virtual environment:

```
../PYT-TwitterWall/ $ python3 -m venv env
../PYT-TwitterWall/ $ . env/bin/activate
(env) ../PYT-TwitterWall/ $ python3 -m pip -r requirements.txt
(env) ../PYT-TwitterWall/ $ python3 twitterwall ...
$ python3 -m venv env
$ . env/bin/activate
(env) $ python3 setup.py install
(env) $ twitterwall ...
(env) $ deactivate
$ rm -r env
```

### setup.py

You can use standard `setup.py` file to install the package, after
installation you can run Twitter Wall by just `twitterwall` or as
Python module `python3 -m twitterwall` (again watch you Python version).
Installation can be done system-wide or just in virtual environment.

```
python3 setup.py install
twitterwall ...
python3 -m twitterwall ...
```

### PyPi (testing)

* [https://testpypi.python.org/pypi/twitterwall](https://testpypi.python.org/pypi/twitterwall)

(env) ../PYT-TwitterWall/ $ deactivate
../PYT-TwitterWall/ $ rm -r env
You can use pip (and the Test PyPi) to install package **twitterwall**:

```
pip install --extra-index-url https://testpypi.python.org/pypi twitterwall
```

* _NOTE_: You can not use only the `-i`, because some of the required
packages are not in the Test PyPi.

Again you can run this command system-wide (watch you Python version) or
setup virtual environment first.

### Install tested environment

Twitter Wall is tested in environment with packages & versions noted in
the `requirements.txt` file (made by `pip freeze`). So you can install
identical environment by:

```
(env) ../PYT-TwitterWall/ $ python3 -m pip -r requirements.txt
```

### Twitter API key
Expand All @@ -57,7 +97,7 @@ First you need config file with your API key & secret. Default path is `config/a
can be set different via `--config` option:

```
python twitterwall --config <file> [web|cli] ...
twitterwall --config <file> [web|cli] ...
```

### CLI
Expand Down Expand Up @@ -86,21 +126,21 @@ Moreover you can use:
Show help how to use **TwitterWall**:

```
python twitterwall cli --help
twitterwall cli --help
```

Show only czech tweets (no retweets) with hashtag **#python**:

```
python twitterwall cli -q "#python" --no-retweets --lang "cs"
twitterwall cli -q "#python" --no-retweets --lang "cs"
```

Show only czech tweets (no retweets) with text **swag**,
check every 1 second, load 20 tweets at start and don't use any
CLI output styling at all:

```
python twitterwall cli -q "swag" -i 1 -n 20 --no-swag
twitterwall cli -q "swag" -i 1 -n 20 --no-swag
```

Filter loaded tweets with word **python** by allowing only authors **hroncok**
Expand All @@ -110,26 +150,26 @@ and **EnCuKou** ([MI-PYT](https://github.com/cvut/MI-PYT) teachers):
will be shown at the start, because are not in last 5 tweets containing word "python".

```
python twitterwall cli -q "python" -a "hroncok" -a "EnCuKou"
python twitterwall cli -q "python" -a "hroncok" -a "encukou"
twitterwall cli -q "python" -a "hroncok" -a "EnCuKou"
twitterwall cli -q "python" -a "hroncok" -a "encukou"
```

Filter loaded tweets with word **python** by blocking authors **hroncok**
and **EnCuKou** ([MI-PYT](https://github.com/cvut/MI-PYT) teachers), so it
will hide all tweets by them:

```
python twitterwall cli -q "python" -b "hroncok" -b "EnCuKou"
python twitterwall cli -q "python" -b "hroncok" -b "encukou"
twitterwall cli -q "python" -b "hroncok" -b "EnCuKou"
twitterwall cli -q "python" -b "hroncok" -b "encukou"
```

Filter loaded tweets with word **python** by allowing only tweets with
number of retweets between 10 and 100 and from authors that have at least
300 followers but also less than 3000:

```
python twitterwall cli -q "python" --retweets-min 10 --retweets-max 100 \
--followers-min 300 --followers-max 3000
twitterwall cli -q "python" --retweets-min 10 --retweets-max 100 \
--followers-min 300 --followers-max 3000
```

#### Output sample
Expand Down Expand Up @@ -170,24 +210,24 @@ _Example_: [mareksuchanek.pythonanywhere.com](http://mareksuchanek.pythonanywher
Here is also `--help` as for the `cli` command:

```
python twitterwall web --help
twitterwall web --help
```

Start web interface with loading 7 tweets at start and 10 seconds interval of AJAX requests (when turned on by user).

* _NOTE_: Minimal value of interval is defined as 3 seconds.

```
python twitterwall web --count 7 --interval 10
python twitterwall web -n 7 -i 10
twitterwall web --count 7 --interval 10
twitterwall web -n 7 -i 10
```

Start web interface with default values (5 tweets and 5 seconds), but turn on debugging.

* _NOTE_: Should not be used on production! :confounded:

```
python twitterwall web --debug
twitterwall web --debug
```

#### Screenshots
Expand Down
12 changes: 8 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# TwitterWall
# TwitterWall tested environment
# pip install -r requirements.txt
#================================
click >= 6.6
requests >= 2.10.0
flask >= 0.10.0
click==6.6
Flask==0.11.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
requests==2.11.1
Werkzeug==0.11.11
52 changes: 52 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from setuptools import setup, find_packages

with open('README.md') as f:
long_description = ''.join(f.readlines())

setup(
name='twitterwall',
version='0.3',
keywords='twitter feed cli web tweet wall',
description='Simple CLI & WEB based Twitter tweets feed',
long_description=long_description,
author='Marek Suchánek',
author_email='[email protected]',
license='MIT',
url='https://github.com/MarekSuchanek/PYT-TwitterWall',
zip_safe=False, # http://flask.pocoo.org/docs/0.11/patterns/distribute/
packages=find_packages(),
package_data={
'twitterwall': [
'static/*.*',
'static/fonts/*.*',
'static/images/*.*',
'templates/*.html'
]
},
entry_points={
'console_scripts': [
'twitterwall = twitterwall.cli:twitter_wall',
],
},
install_requires=[
'Flask>=0.10.0',
'Jinja2>=2.6',
'click>=6.6',
'requests>=2.10.0'
],
classifiers=[
'Environment :: Console',
'Environment :: Web Environment',
'Framework :: Flask',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Topic :: Communications',
'Topic :: Internet',
'Topic :: Sociology'
],
)
4 changes: 4 additions & 0 deletions twitterwall/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .common import Tweet, TwitterConnection
from .cli import CLIColorfulWall, CLIWall, TweetReader

__all__ = ['Tweet','TweetReader', 'TwitterConnection', 'CLIWall', 'CLIColorfulWall']
2 changes: 1 addition & 1 deletion twitterwall/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from cli import twitter_wall
from .cli import twitter_wall

twitter_wall()
6 changes: 3 additions & 3 deletions twitterwall/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import signal
import sys
import time
from common import *
from web import start_web
from .common import TwitterConnection
from .web import start_web

wall = None
twitter = None
Expand Down Expand Up @@ -152,7 +152,7 @@ def print_bye(self, text):
click.secho(text, fg=self.colors['bye'], bold=True)


@click.group()
@click.group(name="twitterwall")
@click.option('--config', '-c', default='config/auth.cfg',
type=click.File('r'), help='App config file path.')
@click.version_option(version='0.2', prog_name='TwitterWall')
Expand Down
2 changes: 1 addition & 1 deletion twitterwall/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import jinja2
import configparser
import json
from common import *
from .common import TwitterConnection

app = flask.Flask(__name__)
twitter = None
Expand Down

0 comments on commit 858eda8

Please sign in to comment.