Browse Source

Now building into a package like a normal person.

Signed-off-by: Abrax <abrax@teknik.io>
master
Abrax 4 years ago
parent
commit
8558599c30
10 changed files with 60 additions and 28 deletions
  1. 3
    0
      .gitignore
  2. 19
    10
      README
  3. 2
    0
      build.sh
  4. 2
    2
      constants.py
  5. 1
    5
      db_methods.py
  6. 2
    4
      file_io.py
  7. 3
    0
      install.sh
  8. 12
    4
      lizard.py
  9. 0
    3
      requirements.txt
  10. 16
    0
      setup.py

+ 3
- 0
.gitignore View File

@@ -3,3 +3,6 @@ __pycache__/*
logic/__pycache__/*
data/*
threads.db*
build/*
dist/*
lizard.egg-info/*

Readme.md → README View File

@@ -2,29 +2,38 @@
lizard is a command line (CLI) program for monitoring 8ch threads. After you add a thread to its watchlist, it can connect to 8ch and check if new replies were made, notifying you if so. It will attempt to save the thread and the files in it in case the thread dies. It can also open all threads with new replies in your browser with a single command.

## Installation
1. Make sure you have Python3 installed.
2. Download the repo and put the files into a directory you want.
3. Satisfy all the Python package dependencies. Running `pip install -r requirements.txt` from the lizard directory should automatically install them, unless I messed up (I have to manually update this file). If that doesn't work try looking at the source files and see what dependencies are missing (and submit an issue so I can try to fix it).
4. Give `lizard.py` permission to execute so you can run it with `./lizard.py` instead of having to do `python3 lizard.py`.

### Linux

1. Download the most recent package from under `dist/`
2. Extract this into your root directory: `sudo tar -zvxf dist/lizard-0.1.linux-x86_64.tar.gz -C /`

If you don't have the most recent Python3 installed and run into a problem, update your Python3 installation and try again.

### Running sources directly

You can also run the `.py` files in the repo directly. If you want to do this I'm assuming you have enough proficiency with Python to figure it out. FYI, I use PyCharm to develop so it might be easier to get it to work with it.

## Usage
On a Linux system, you can run `lizard` by `cd`ing to the directory and typing `./lizard.py`. `lizard` must be invoked with a correct set of command line arguments, otherwise it will print a help message explaining the syntax.
Running `lizard` without any arguments will print the help message explaining the syntax. It will also create a `~/lizard_data` directory to store files.

On the first run, you must create a new database file to store data about the watched threads: `./lizard.py i`
After you install, run `lizard c` to create a new database. Everything else will crash unless a valid database exists.

Add a thread to the database with: `./lizard a <URL>` Upon adding a thread, `lizard` will immediately download a copy of the thread and the files in it. These will be put under `/data/` inside the directory where you put the `lizard` scripts.
Add a thread to the database with: `lizard a <URL>` Upon adding a thread, `lizard` will immediately download a copy of the thread and the files in it. These will be put under `/data/` inside the directory where you put the `lizard` scripts.
## FAQ
### Is `lizard` only for Linux?
It's in Python so should work anywhere. However being CLI, it could be inconvenient to work with in Windows, which tends to have poor CLIs. I wrote it for use on Linux and it will probably be most convenient in a Linux command line.
It's easy for me to build the Linux package, so I only supply that.

Python is supposed to be cross-platform so it should work on other OSes too. If anyone is actually interested in running it on something else, I can try to build for that also.

### Is there a GUI?
No. An earlier version of this program had a GUI, but it turned out to be more trouble than it's worth.

### Why doesn't `lizard` automatically refresh threads at set intervals?
Since Linux systems already have ways of scheduling automatic execution of programs, such as `cron`, I deliberately left out this feature. You can set a scheduled job that runs `./lizard.py r` at a frequency that suits you.
Since Linux systems already have ways of scheduling automatic execution of programs, such as `cron`, I deliberately left out this feature. You can set a scheduled job that runs `lizard.py rc` at a frequency that suits you.

### How can I see what's in the database?
`./lizard l` will print out a summary, but if you want the nitty gritty I recommend the SQLite browser `sqliteman`. You can see the tables and alter them as you wish.
`lizard l` will print out a summary, but if you want the nitty gritty I recommend the SQLite browser `sqliteman`. You can see the tables and alter them as you wish.

### Why does it create so many `.json` and `.html` files in the data directory?
These are saved at each refresh in case the thread dies or any replies are deleted. Periodically clearing the older files is left up to the user.

+ 2
- 0
build.sh View File

@@ -0,0 +1,2 @@
#! /bin/bash
python setup.py bdist

+ 2
- 2
constants.py View File

@@ -1,5 +1,5 @@
cache_directory = 'data'
lizard_data_directory = 'lizard_data'
files_directory = 'files'
orm_db_path = 'data/threads.orm.db'
orm_db_path = 'threads.orm.db'
user_agent = 'https://git.teknik.io/abrax/lizard'
conservative_refresh_criterion = 10

+ 1
- 5
db_methods.py View File

@@ -21,10 +21,6 @@ def create_new_database():
if os.path.exists(constants.orm_db_path):
print(constants.orm_db_path + ' already exists, doing nothing.')
else:
db_dir = os.path.dirname(constants.orm_db_path)
if not os.path.exists(db_dir):
os.makedirs(db_dir)

db = SqliteDatabase(constants.orm_db_path)
db.connect()
Thread.create_table()
@@ -189,6 +185,6 @@ def export_thread_list():
threads = Thread.select()
print('Exporting {} threads.'.format(len(threads)))

with open(os.path.join(constants.cache_directory, 'Exported {}.txt'.format(time_methods.timestamp_now())), 'w') as f:
with open(os.path.join('Exported {}.txt'.format(time_methods.timestamp_now())), 'w') as f:
for t in threads:
f.write('./lizard.py a "{}"\n'.format(t.original_url))

+ 2
- 4
file_io.py View File

@@ -1,6 +1,6 @@
import os

from constants import files_directory, cache_directory
from constants import files_directory


def save_file(file_path, file_contents):
@@ -40,7 +40,5 @@ def path_to_cached_file(board, thread_no, normalized_filename):


def path_to_thread_cache(board, thread_no):
p = os.path.join(cache_directory,
board,
thread_no)
p = os.path.join(board, thread_no)
return p

+ 3
- 0
install.sh View File

@@ -0,0 +1,3 @@
#! /bin/bash
sudo tar -zvxf dist/lizard-0.1.linux-x86_64.tar.gz -C /


+ 12
- 4
lizard.py View File

@@ -3,6 +3,7 @@ import os
import sys

import db_methods
from constants import lizard_data_directory


def help_info():
@@ -42,13 +43,16 @@ Available commands:
exit()


if __name__ == '__main__':
os.chdir(sys.path[0]) # set working directory to this script's directory
def main():
# Set working directory to be the specified path under the home folder
from os.path import expanduser
lizard_dir = os.path.join(expanduser("~"), lizard_data_directory)
if not os.path.exists(lizard_dir): os.makedirs(lizard_dir)
os.chdir(lizard_dir)

n = len(sys.argv)
if n < 2: help_info()
command = sys.argv[1]

if n == 2:
if command == 'l':
db_methods.list_threads()
@@ -79,6 +83,10 @@ if __name__ == '__main__':
if command == 'd':
db_methods.remove_thread_by_id(sys.argv[2], sys.argv[3])
else:
help_info()
help_info()
else:
help_info()


if __name__ == '__main__':
main()

+ 0
- 3
requirements.txt View File

@@ -1,3 +0,0 @@
requests
peewee
humanize

+ 16
- 0
setup.py View File

@@ -0,0 +1,16 @@
from setuptools import setup

setup(
name='lizard',
version='0.1',
packages=[''],
url='https://git.teknik.io/abrax/lizard',
license='MIT',
author='abrax',
author_email='abrax@teknik.io',
description='lizard, the 8ch monitor',

entry_points = {'console_scripts': ['lizard = lizard:main']},

install_requires = ['requests', 'peewee', 'humanize']
)

Loading…
Cancel
Save