Skip to content

Commit

Permalink
Merge pull request #3 from gri-gus/v1.2
Browse files Browse the repository at this point in the history
v1.2.0
Transition to streamdeck-sdk==1.0.0;
Refusal of src folder;
  • Loading branch information
gri-gus authored Aug 31, 2024
2 parents a897c0b + be49dca commit 39dd147
Show file tree
Hide file tree
Showing 32 changed files with 96 additions and 92 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Stream Deck Plugin for installing images from LoremFlickr to button.
* MacOS: 10.14 or later
* Windows: 10 or later

**Stream Deck application:** 6.0, 6.1
**Stream Deck application:** 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6

**Python:** 3.8 or later

Expand Down Expand Up @@ -93,7 +93,7 @@ After installation, you will have a `LoremFlickr` category and actions:

## Usage

> ⚠️ The button may not start working immediately after installing the plugin, but after about 20 seconds. At this time,
> ⚠️ The button may not start working immediately after installing the plugin, but after about 40 seconds. At this time,
> dependencies are installed. If you do not receive an error message on the screen, but an exclamation mark is displayed
> when you click on the button, then the plugin is not fully installed yet, and you need to wait. This only happens
> after installing the plugin. There is no need to wait for the next use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
StreamDeck,
Action,
events_received_objs,
events_sent_objs,
image_bytes_to_base64,
logger,
)
Expand Down Expand Up @@ -59,11 +58,9 @@ def on_key_down(self, obj: events_received_objs.KeyDown):

self.set_image(
context=obj.context,
payload=events_sent_objs.SetImagePayload(
image=image_base64,
target=0,
state=obj.payload.state,
)
image=image_base64,
target=0,
state=obj.payload.state,
)


Expand Down
12 changes: 12 additions & 0 deletions com.ggusev.loremflickr.sdPlugin/code/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
annotated-types==0.7.0
certifi==2024.8.30
charset-normalizer==3.3.2
decohints==1.0.9
idna==3.8
pydantic==2.8.2
pydantic_core==2.20.1
requests==2.32.3
streamdeck-sdk==1.0.0
typing_extensions==4.12.2
urllib3==2.2.2
websockets==13.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import os
from pathlib import Path

PLUGIN_LOGS_DIR_PATH: Path = Path(os.environ["PLUGIN_LOGS_DIR_PATH"])
PLUGIN_NAME: str = os.environ["PLUGIN_NAME"]

PLUGIN_LOGS_DIR_PATH: Path = Path(os.environ.get("PLUGIN_LOGS_DIR_PATH", Path(__file__).parents[2] / "logs"))
PLUGIN_NAME: str = os.environ.get("PLUGIN_NAME", Path(__file__).parents[1].name)
LOG_FILE_PATH: Path = PLUGIN_LOGS_DIR_PATH / Path(f"{PLUGIN_NAME}.log")
LOG_LEVEL: int = logging.DEBUG

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import os
import platform
import re
import shlex
import subprocess
Expand Down Expand Up @@ -115,16 +116,20 @@ def install_requirements_daemon() -> subprocess.Popen:


def pip_freeze_daemon() -> subprocess.Popen:
if sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
os_name = platform.system()
logger.info(os_name)
if os_name == "Darwin":
command = f'''
"{PLUGIN_CODE_VENV_ACTIVATE}" &&\
source "{PLUGIN_CODE_VENV_ACTIVATE}" &&\
{PYTHON_COMMAND} -m pip freeze\
'''
else:
elif os_name == "Windows":
command = f'''
source "{PLUGIN_CODE_VENV_ACTIVATE}" &&\
"{PLUGIN_CODE_VENV_ACTIVATE}" &&\
{PYTHON_COMMAND} -m pip freeze\
'''
else:
raise InitError("Unsupported Operation System.")
process = subprocess.Popen(
clean_up_command(command),
stdout=subprocess.PIPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Description": "Get images from LoremFlickr",
"Icon": "assets/plugin_icon",
"Name": "LoremFlickr",
"Version": "1.1.2",
"Version": "1.2.0",
"SDKVersion": 2,
"OS": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
@echo off

SET PYTHON_COMMAND=python
SET PYTHON_OK_VERSION=Python 3
SET PYTHON_MINIMUM_VERSION=3.8

SET BASE_PATH=%~dp0
SET PLUGIN_DIR_PATH=%BASE_PATH:~0,-1%
for %%I in ("%PLUGIN_DIR_PATH%") do set PLUGIN_NAME=%%~nxI
SET PLUGIN_LOGS_DIR_PATH=%PLUGIN_DIR_PATH%\logs
SET PYTHON_INIT_PATH=%PLUGIN_DIR_PATH%\init.py

SET PLUGIN_CODE_DIR_PATH=%PLUGIN_DIR_PATH%\code
SET PLUGIN_CODE_REQUIREMENTS_PATH=%PLUGIN_CODE_DIR_PATH%\requirements.txt
SET PLUGIN_CODE_PATH=%PLUGIN_CODE_DIR_PATH%\main.py

SET PLUGIN_CODE_VENV_DIR_PATH=%PLUGIN_CODE_DIR_PATH%\venv
SET PLUGIN_CODE_VENV_ACTIVATE=%PLUGIN_CODE_VENV_DIR_PATH%\Scripts\Activate
SET PLUGIN_CODE_VENV_PYTHON=%PLUGIN_CODE_VENV_DIR_PATH%\Scripts\python.exe

echo "%PYTHON_COMMAND%"
echo "%PYTHON_OK_VERSION%"
echo "%PYTHON_MINIMUM_VERSION%"

echo "%BASE_PATH%"
echo "%PLUGIN_DIR_PATH%"
echo "%PLUGIN_NAME%"
echo "%PLUGIN_LOGS_DIR_PATH%"
echo "%PYTHON_INIT_PATH%"

echo "%PLUGIN_CODE_DIR_PATH%"
echo "%PLUGIN_CODE_REQUIREMENTS_PATH%"
echo "%PLUGIN_CODE_PATH%"

echo "%PLUGIN_CODE_VENV_DIR_PATH%"
echo "%PLUGIN_CODE_VENV_ACTIVATE%"
echo "%PLUGIN_CODE_VENV_PYTHON%"

FOR /F "tokens=* USEBACKQ" %%F IN (`%PYTHON_COMMAND% -V`) DO SET PYTHON_VERSION=%%F
echo "%PYTHON_VERSION%"

IF "%PYTHON_VERSION%" == "" (
echo "bad python"
powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('%PYTHON_OK_VERSION% not installed', 'StreamDeck \"%PLUGIN_NAME%\" plugin ERROR', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"
exit
)

IF NOT "%PYTHON_VERSION:~0,8%" == "%PYTHON_OK_VERSION%" (
echo "bad python"
powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('%PYTHON_OK_VERSION% not installed', 'StreamDeck \"%PLUGIN_NAME%\" plugin ERROR', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"
exit
)

FOR /F "tokens=* USEBACKQ" %%F IN (`%PYTHON_COMMAND% "%PYTHON_INIT_PATH%"`) DO SET INIT_RESULT=%%F
echo "%INIT_RESULT%"

IF NOT "%INIT_RESULT%" == "True" (
echo "bad python"
powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('%INIT_RESULT%', 'StreamDeck \"%PLUGIN_NAME%\" plugin ERROR', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"
exit
)

SET PYTHONPATH="%PLUGIN_CODE_DIR_PATH%"
echo "%PYTHONPATH%"

"%PLUGIN_CODE_VENV_PYTHON%" "%PLUGIN_CODE_PATH%" %*
@echo off

SET PYTHON_COMMAND=python
SET PYTHON_OK_VERSION=Python 3
SET PYTHON_MINIMUM_VERSION=3.8

SET BASE_PATH=%~dp0
SET PLUGIN_DIR_PATH=%BASE_PATH:~0,-1%
for %%I in ("%PLUGIN_DIR_PATH%") do set PLUGIN_NAME=%%~nxI
SET PLUGIN_LOGS_DIR_PATH=%PLUGIN_DIR_PATH%\logs
SET PYTHON_INIT_PATH=%PLUGIN_DIR_PATH%\init.py

SET PLUGIN_CODE_DIR_PATH=%PLUGIN_DIR_PATH%\code
SET PLUGIN_CODE_REQUIREMENTS_PATH=%PLUGIN_CODE_DIR_PATH%\requirements.txt
SET PLUGIN_CODE_PATH=%PLUGIN_CODE_DIR_PATH%\main.py

SET PLUGIN_CODE_VENV_DIR_PATH=%PLUGIN_CODE_DIR_PATH%\venv
SET PLUGIN_CODE_VENV_ACTIVATE=%PLUGIN_CODE_VENV_DIR_PATH%\Scripts\Activate
SET PLUGIN_CODE_VENV_PYTHON=%PLUGIN_CODE_VENV_DIR_PATH%\Scripts\python.exe

echo "%PYTHON_COMMAND%"
echo "%PYTHON_OK_VERSION%"
echo "%PYTHON_MINIMUM_VERSION%"

echo "%BASE_PATH%"
echo "%PLUGIN_DIR_PATH%"
echo "%PLUGIN_NAME%"
echo "%PLUGIN_LOGS_DIR_PATH%"
echo "%PYTHON_INIT_PATH%"

echo "%PLUGIN_CODE_DIR_PATH%"
echo "%PLUGIN_CODE_REQUIREMENTS_PATH%"
echo "%PLUGIN_CODE_PATH%"

echo "%PLUGIN_CODE_VENV_DIR_PATH%"
echo "%PLUGIN_CODE_VENV_ACTIVATE%"
echo "%PLUGIN_CODE_VENV_PYTHON%"

FOR /F "tokens=* USEBACKQ" %%F IN (`%PYTHON_COMMAND% -V`) DO SET PYTHON_VERSION=%%F
echo "%PYTHON_VERSION%"

IF "%PYTHON_VERSION%" == "" (
echo "bad python"
powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('%PYTHON_OK_VERSION% not installed', 'StreamDeck \"%PLUGIN_NAME%\" plugin ERROR', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"
exit
)

IF NOT "%PYTHON_VERSION:~0,8%" == "%PYTHON_OK_VERSION%" (
echo "bad python"
powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('%PYTHON_OK_VERSION% not installed', 'StreamDeck \"%PLUGIN_NAME%\" plugin ERROR', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"
exit
)

FOR /F "tokens=* USEBACKQ" %%F IN (`%PYTHON_COMMAND% "%PYTHON_INIT_PATH%"`) DO SET INIT_RESULT=%%F
echo "%INIT_RESULT%"

IF NOT "%INIT_RESULT%" == "True" (
echo "bad python"
powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show('%INIT_RESULT%', 'StreamDeck \"%PLUGIN_NAME%\" plugin ERROR', 'OK', [System.Windows.Forms.MessageBoxIcon]::Information);}"
exit
)

SET PYTHONPATH="%PLUGIN_CODE_DIR_PATH%"
echo "%PYTHONPATH%"

"%PLUGIN_CODE_VENV_PYTHON%" "%PLUGIN_CODE_PATH%" %*
1 change: 1 addition & 0 deletions src/com.ggusev.loremflickr.sdPlugin/run.sh → com.ggusev.loremflickr.sdPlugin/run.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ export PYTHONPATH="${PLUGIN_CODE_DIR_PATH}"
echo $PYTHONPATH

"${PLUGIN_CODE_VENV_PYTHON}" "${PLUGIN_CODE_PATH}" "$@"
osascript -e "display dialog \"$@\""
10 changes: 0 additions & 10 deletions src/com.ggusev.loremflickr.sdPlugin/code/requirements.txt

This file was deleted.

0 comments on commit 39dd147

Please sign in to comment.