Skip to content

Commit 4947005

Browse files
committed
added linux executable and adjusted log levels with flag
1 parent 646cae7 commit 4947005

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ config.yaml
88
build/
99
david.spec
1010
dist.zip
11-
dist/
1211
.david.cred
1312
.david.key
1413
username.txt

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ It uses the David Social API and allows you to read posts from your friends, lik
1414
* (OPTIONAL) [Pyenv](https://github.com/pyenv/pyenv) for a virtual environment
1515

1616
## Installation
17+
18+
### Linux Executable
19+
A pre-built executable is available for your executing pleasure.
20+
Instructions:
21+
1. `cp dist/david /usr/bin` (may require elevation)
22+
2. you can now run david with the david command `david`
23+
24+
### Windows and Mac Executables
25+
There is currently no standalone executable for Windows or Mac. Maybe there will be one day :)
26+
1727
### Using Make
1828
1. Clone this repository
1929
2. `make all` will setup a Pyenv virtual environment and install the required libraries

david.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env
22

33
import os
4+
import sys
45
import logging
56
import atexit
67
import curses
@@ -12,6 +13,7 @@
1213
import scripts.api_routes as david_api
1314
from scripts.states import StateMain
1415
import scripts.config as config
16+
import scripts.file_utils as utils
1517

1618
# Initialise curses
1719
stdscr = curses.initscr()
@@ -27,11 +29,13 @@
2729
def logging_init():
2830
"""Createss a logfile with the current date and time"""
2931
# Make a logs directory if it doesn't exist
30-
if not os.path.exists("logs"):
31-
os.mkdir("logs")
32+
base_dir = f"{utils.get_home_dir()}/.david_logs"
33+
if not os.path.exists(base_dir):
34+
os.mkdir(base_dir)
3235
# Create a logfile with the current date and time
33-
filename = f"logs/{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
34-
logging.basicConfig(filename=filename, level=logging.DEBUG, encoding="utf-8")
36+
log_level = logging.DEBUG if "--logs" in sys.argv else logging.CRITICAL
37+
filename = f"{base_dir}/{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
38+
logging.basicConfig(filename=filename, level=log_level, encoding="utf-8")
3539
print(f"Logging to {filename}")
3640
logger = logging.getLogger()
3741
return filename, logger

dist/david

18.6 MB
Binary file not shown.

pyimake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyinstaller --onefile --add-data assets:assets david.py

scripts/states.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ def __init__(self, stdscr, session, logger):
797797
self.cat_kaomoji_list = []
798798

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

0 commit comments

Comments
 (0)