Skip to content

Commit

Permalink
added linux executable and adjusted log levels with flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdmrn committed Jan 21, 2024
1 parent 646cae7 commit 4947005
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ config.yaml
build/
david.spec
dist.zip
dist/
.david.cred
.david.key
username.txt
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ It uses the David Social API and allows you to read posts from your friends, lik
* (OPTIONAL) [Pyenv](https://github.com/pyenv/pyenv) for a virtual environment

## Installation

### Linux Executable
A pre-built executable is available for your executing pleasure.
Instructions:
1. `cp dist/david /usr/bin` (may require elevation)
2. you can now run david with the david command `david`

### Windows and Mac Executables
There is currently no standalone executable for Windows or Mac. Maybe there will be one day :)

### Using Make
1. Clone this repository
2. `make all` will setup a Pyenv virtual environment and install the required libraries
Expand Down
12 changes: 8 additions & 4 deletions david.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env

import os
import sys
import logging
import atexit
import curses
Expand All @@ -12,6 +13,7 @@
import scripts.api_routes as david_api
from scripts.states import StateMain
import scripts.config as config
import scripts.file_utils as utils

# Initialise curses
stdscr = curses.initscr()
Expand All @@ -27,11 +29,13 @@
def logging_init():
"""Createss a logfile with the current date and time"""
# Make a logs directory if it doesn't exist
if not os.path.exists("logs"):
os.mkdir("logs")
base_dir = f"{utils.get_home_dir()}/.david_logs"
if not os.path.exists(base_dir):
os.mkdir(base_dir)
# Create a logfile with the current date and time
filename = f"logs/{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
logging.basicConfig(filename=filename, level=logging.DEBUG, encoding="utf-8")
log_level = logging.DEBUG if "--logs" in sys.argv else logging.CRITICAL
filename = f"{base_dir}/{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
logging.basicConfig(filename=filename, level=log_level, encoding="utf-8")
print(f"Logging to {filename}")
logger = logging.getLogger()
return filename, logger
Expand Down
Binary file added dist/david
Binary file not shown.
1 change: 1 addition & 0 deletions pyimake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyinstaller --onefile --add-data assets:assets david.py
2 changes: 1 addition & 1 deletion scripts/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def __init__(self, stdscr, session, logger):
self.cat_kaomoji_list = []

try:
with open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "assets/kaomoji.csv"), "r") as f:
with open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "assets/kaomoji.csv"), "r", encoding="utf-8") as f:
reader = csv.reader(f)
for row in reader:
self.cat_kaomoji_list.append(row[0])
Expand Down

0 comments on commit 4947005

Please sign in to comment.