Improved setup and deploy
This commit is contained in:
parent
58d318faee
commit
d3a641e1f8
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@ keys.py
|
||||
*.pyc
|
||||
.cache/
|
||||
test.png
|
||||
wifi_networks.yml
|
||||
wifi_networks.yml
|
||||
program_variables.yml
|
||||
|
1
Pipfile
1
Pipfile
@ -6,6 +6,7 @@ name = "pypi"
|
||||
[packages]
|
||||
pillow = "*"
|
||||
httpx = "*"
|
||||
pyyaml = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
|
89
Pipfile.lock
generated
89
Pipfile.lock
generated
@ -1,7 +1,7 @@
|
||||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "67ce1ab808a1bcb6013a54e3d675786aaa8852f6a8a94d3df78c600503cc1e2a"
|
||||
"sha256": "8fd64e8e7662ff58ccf2dc70efbc2cedb3e07283b6e791eaa7bc410172505306"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
@ -18,19 +18,19 @@
|
||||
"default": {
|
||||
"anyio": {
|
||||
"hashes": [
|
||||
"sha256:cfdb2b588b9fc25ede96d8db56ed50848b0b649dca3dd1df0b11f683bb9e0b5f",
|
||||
"sha256:f7ed51751b2c2add651e5747c891b47e26d2a21be5d32d9311dfe9692f3e5d7a"
|
||||
"sha256:745843b39e829e108e518c489b31dc757de7d2131d53fac32bd8df268227bfee",
|
||||
"sha256:e1875bb4b4e2de1669f4bc7869b6d3f54231cdced71605e6e64c9be77e3be50f"
|
||||
],
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==4.0.0"
|
||||
"version": "==4.2.0"
|
||||
},
|
||||
"certifi": {
|
||||
"hashes": [
|
||||
"sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082",
|
||||
"sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"
|
||||
"sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1",
|
||||
"sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"
|
||||
],
|
||||
"markers": "python_version >= '3.6'",
|
||||
"version": "==2023.7.22"
|
||||
"version": "==2023.11.17"
|
||||
},
|
||||
"h11": {
|
||||
"hashes": [
|
||||
@ -42,28 +42,28 @@
|
||||
},
|
||||
"httpcore": {
|
||||
"hashes": [
|
||||
"sha256:13b5e5cd1dca1a6636a6aaea212b19f4f85cd88c366a2b82304181b769aab3c9",
|
||||
"sha256:adc5398ee0a476567bf87467063ee63584a8bce86078bf748e48754f60202ced"
|
||||
"sha256:096cc05bca73b8e459a1fc3dcf585148f63e534eae4339559c9b8a8d6399acc7",
|
||||
"sha256:9fc092e4799b26174648e54b74ed5f683132a464e95643b226e00c2ed2fa6535"
|
||||
],
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==0.18.0"
|
||||
"version": "==1.0.2"
|
||||
},
|
||||
"httpx": {
|
||||
"hashes": [
|
||||
"sha256:181ea7f8ba3a82578be86ef4171554dd45fec26a02556a744db029a0a27b7100",
|
||||
"sha256:47ecda285389cb32bb2691cc6e069e3ab0205956f681c5b2ad2325719751d875"
|
||||
"sha256:451b55c30d5185ea6b23c2c793abf9bb237d2a7dfb901ced6ff69ad37ec1dfaf",
|
||||
"sha256:8915f5a3627c4d47b73e8202457cb28f1266982d1159bd5779d86a80c0eab1cd"
|
||||
],
|
||||
"index": "pypi",
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==0.25.0"
|
||||
"version": "==0.26.0"
|
||||
},
|
||||
"idna": {
|
||||
"hashes": [
|
||||
"sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4",
|
||||
"sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"
|
||||
"sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca",
|
||||
"sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"
|
||||
],
|
||||
"markers": "python_version >= '3.5'",
|
||||
"version": "==3.4"
|
||||
"version": "==3.6"
|
||||
},
|
||||
"pillow": {
|
||||
"hashes": [
|
||||
@ -126,6 +126,63 @@
|
||||
"markers": "python_version >= '3.8'",
|
||||
"version": "==10.1.0"
|
||||
},
|
||||
"pyyaml": {
|
||||
"hashes": [
|
||||
"sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5",
|
||||
"sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc",
|
||||
"sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df",
|
||||
"sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741",
|
||||
"sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206",
|
||||
"sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27",
|
||||
"sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595",
|
||||
"sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62",
|
||||
"sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98",
|
||||
"sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696",
|
||||
"sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290",
|
||||
"sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9",
|
||||
"sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d",
|
||||
"sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6",
|
||||
"sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867",
|
||||
"sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47",
|
||||
"sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486",
|
||||
"sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6",
|
||||
"sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3",
|
||||
"sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007",
|
||||
"sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938",
|
||||
"sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0",
|
||||
"sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c",
|
||||
"sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735",
|
||||
"sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d",
|
||||
"sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28",
|
||||
"sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4",
|
||||
"sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba",
|
||||
"sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8",
|
||||
"sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5",
|
||||
"sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd",
|
||||
"sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3",
|
||||
"sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0",
|
||||
"sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515",
|
||||
"sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c",
|
||||
"sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c",
|
||||
"sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924",
|
||||
"sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34",
|
||||
"sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43",
|
||||
"sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859",
|
||||
"sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673",
|
||||
"sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54",
|
||||
"sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a",
|
||||
"sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b",
|
||||
"sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab",
|
||||
"sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa",
|
||||
"sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c",
|
||||
"sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585",
|
||||
"sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d",
|
||||
"sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"
|
||||
],
|
||||
"index": "pypi",
|
||||
"markers": "python_version >= '3.6'",
|
||||
"version": "==6.0.1"
|
||||
},
|
||||
"sniffio": {
|
||||
"hashes": [
|
||||
"sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101",
|
||||
|
@ -8,11 +8,13 @@
|
||||
repo_dest: /home/remy/eink
|
||||
code_dest: /home/remy/eink/src
|
||||
service_target_dir: /etc/systemd/system/
|
||||
# adapt to taste
|
||||
own_image_percent: 90
|
||||
recipient: "???"
|
||||
|
||||
tasks:
|
||||
- name: Load program variables
|
||||
ansible.builtin.include_vars:
|
||||
file: ../program_variables.yml
|
||||
name: program_variables
|
||||
|
||||
- name: Pull the latest version of the code
|
||||
git:
|
||||
repo: https://git.kluster.moll.re/remoll/rpi-eink-picture-frame
|
||||
@ -32,11 +34,6 @@
|
||||
args:
|
||||
chdir: "{{ repo_dest }}"
|
||||
|
||||
- name: Copy keys python file
|
||||
copy:
|
||||
src: ../src/keys.py
|
||||
dest: "{{ code_dest }}/keys.py"
|
||||
|
||||
- name: Copy unit files
|
||||
template:
|
||||
src: ./templates/{{ item }}.j2
|
||||
@ -55,4 +52,4 @@
|
||||
loop:
|
||||
- eink-show.service
|
||||
- eink-show.timer
|
||||
become: true
|
||||
become: true
|
||||
|
@ -4,19 +4,20 @@
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
# DONE BY RPI IMAGER
|
||||
# - name: Add local ssh key
|
||||
# ansible.posix.authorized_key:
|
||||
# user: "{{ ansible_user }}"
|
||||
# state: present
|
||||
# # copy file present on the controller to the remote host
|
||||
# key: "{{ lookup('file', '~/.ssh/default.pub') }}"
|
||||
|
||||
- name: Include network variables
|
||||
ansible.builtin.include_vars:
|
||||
file: wifi_networks.yml
|
||||
name: wifi_external
|
||||
|
||||
- name: Use raspi-config to set WIFI country
|
||||
shell: |
|
||||
raspi-config nonint do_wifi_country CH
|
||||
|
||||
- name: Use raspi-config to set WIFI SSID and password
|
||||
shell: |
|
||||
raspi-config nonint do_wifi_ssid_passphrase "{{ item.ssid }}" "{{ item.password }}"
|
||||
loop: "{{ wifi_external.networks }}"
|
||||
|
||||
- name: apt update all packages
|
||||
apt:
|
||||
update_cache: yes
|
||||
@ -57,13 +58,3 @@
|
||||
wait_for_connection:
|
||||
delay: 5
|
||||
timeout: 300
|
||||
|
||||
- name: Use raspi-config to set WIFI country
|
||||
shell: |
|
||||
raspi-config nonint do_wifi_country CH
|
||||
|
||||
- name: Use raspi-config to set WIFI SSID and password
|
||||
shell: |
|
||||
raspi-config nonint do_wifi_ssid_passphrase "{{ item.ssid }}" "{{ item.password }}"
|
||||
loop: "{{ wifi_external.networks }}"
|
||||
|
||||
|
@ -6,9 +6,11 @@ Type=oneshot
|
||||
User={{ ansible_user }}
|
||||
WorkingDirectory={{ code_dest }}
|
||||
ExecStart=python main.py
|
||||
Environment="OWN_IMAGE_PERCENT={{ own_image_percent }}"#
|
||||
Environment="RECIPIENT={{ recipient }}"
|
||||
|
||||
Environment="OWN_IMAGE_PERCENT={{ program_variables.OWN_IMAGE_PERCENT }}"
|
||||
Environment="RECIPIENT={{ program_variables.RECIPIENT }}"
|
||||
Environment="IMMICH_API_URL={{ program_variables.IMMICH_API_URL }}"
|
||||
Environment="IMMICH_API_KEY={{ program_variables.IMMICH_API_KEY }}"
|
||||
Environment="IMMICH_ALBUM_ID={{ program_variables.IMMICH_ALBUM_ID }}"
|
||||
|
||||
|
||||
[Install]
|
||||
|
@ -4,13 +4,13 @@ from .museum import ImageGetMuseum
|
||||
import random
|
||||
import os
|
||||
|
||||
igetter = ImageGetImmich()
|
||||
ugettter = ImageGetUnsplash()
|
||||
mgetter = ImageGetMuseum()
|
||||
|
||||
class ImageGetCombined:
|
||||
|
||||
def __init__(self) -> None:
|
||||
igetter = ImageGetImmich()
|
||||
ugettter = ImageGetUnsplash()
|
||||
mgetter = ImageGetMuseum()
|
||||
|
||||
own_image_percent = int(os.getenv("OWN_IMAGE_PERCENT", 90))
|
||||
other_image_percent = int(100 - own_image_percent)
|
||||
self.getters = [igetter] * own_image_percent \
|
||||
|
@ -1,25 +1,29 @@
|
||||
import keys
|
||||
import httpx as h
|
||||
import random
|
||||
import json
|
||||
import os
|
||||
|
||||
from .template import ImageGet, ImageGetException
|
||||
|
||||
class ImageGetImmich(ImageGet):
|
||||
|
||||
def __init__(self) -> None:
|
||||
api_root_url = os.getenv("IMMICH_API_URL")
|
||||
api_key = os.getenv("IMMICH_API_KEY")
|
||||
|
||||
headers = {
|
||||
"x-api-key": keys.immich_api_key
|
||||
"x-api-key": api_key
|
||||
}
|
||||
|
||||
super().__init__(
|
||||
base_url=keys.immich_api_root_url,
|
||||
base_url=api_root_url,
|
||||
headers=headers
|
||||
)
|
||||
|
||||
|
||||
def get_random_image_ids(self, num=1) -> str:
|
||||
url = self.base_url + "album/" + keys.immich_album_id
|
||||
album_id = os.getenv("IMMICH_ALBUM_ID")
|
||||
url = self.base_url + "album/" + album_id
|
||||
headers = self.headers | {"Accept": "application/json"}
|
||||
|
||||
response = h.request("GET", url, headers=headers, data={})
|
||||
|
16
src/main.py
16
src/main.py
@ -4,6 +4,15 @@ from get.combined import ImageGetCombined
|
||||
from get.template import ImageGetException
|
||||
from image_show import ImageShow
|
||||
import notify
|
||||
import os
|
||||
|
||||
if os.getenv("IMMICH_API_URL") is None:
|
||||
# values are not set, import them from local yaml file
|
||||
import yaml
|
||||
with open("../deploy/program_variables.yml", "r") as f:
|
||||
config = yaml.safe_load(f)
|
||||
for key, value in config.items():
|
||||
os.environ[key] = value
|
||||
|
||||
if len(sys.argv) == 2 and sys.argv[1] == "test":
|
||||
print("Running test")
|
||||
@ -12,16 +21,11 @@ if len(sys.argv) == 2 and sys.argv[1] == "test":
|
||||
sys.exit()
|
||||
|
||||
shrink_kwargs = {}
|
||||
# if "dither" in sys.argv:
|
||||
# print("Enabling dithering")
|
||||
# shrink_kwargs["dither"] = True
|
||||
# if "noreduce" in sys.argv:
|
||||
# print("Disabling color reduction")
|
||||
# shrink_kwargs["colors"] = -1
|
||||
if "reduce" in sys.argv:
|
||||
print("Enabling color reduction")
|
||||
shrink_kwargs["reduce_colors"] = True
|
||||
|
||||
|
||||
try:
|
||||
getter = ImageGetCombined()
|
||||
converter = ImageShrink(**shrink_kwargs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user