clinton-hall / nzbToMedia

Provides NZB and Torrent postprocessing To CouchPotatoServer, SickBeard/SickRage, HeadPhones, Mylar and Gamez
GNU General Public License v3.0
673 stars 176 forks source link

Cannot run any python scripts on Synology (nzbToMedia.py / TorrentToMedia.py) #1957

Closed MrCee closed 7 months ago

MrCee commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

Technical Specs

  1. Running on Synology
  2. Python version 'Python 3.10.5'
  3. Download Client 'SABnbzd, Download Station
  4. Intended Media Management 'SickChill, Radarr' Expected behavior

I haven't been able to run any scripts for a few months now

./nzbToMedia.py

-- Cleaning bytecode --
b'Removing __pycache__/\n'
b'Removing __pycache__/\n'

-- Cleaning folders: ['libs', 'core'] --
No folders to clean

-- Cleanup finished --

Traceback (most recent call last):
  File "/volume1/docker/nzbToMedia/./nzbToMedia.py", line 734, in <module>
    import core
  File "/volume1/docker/nzbToMedia/core/__init__.py", line 52, in <module>
    from core import logger, main_db, version_check, databases, transcoder
  File "/volume1/docker/nzbToMedia/core/logger.py", line 10, in <module>
    import logging
ModuleNotFoundError: No module named 'logging'

I have tried a fresh git clone and dropped the autoProcessMedia.cfg in the new clone.

Any suggestions?

Ive tested all of them to see if they will run, they don't run. I'd still like to use TorrentToMedia.py with Download Station

./TorrentToMedia.py 

-- Cleaning bytecode --
b'Removing __pycache__/\n'
b'Removing __pycache__/\n'

-- Cleaning folders: ['libs', 'core'] --
No folders to clean

-- Cleanup finished --

Traceback (most recent call last):
  File "/volume1/docker/nzbToMedia/./TorrentToMedia.py", line 20, in <module>
    import core
  File "/volume1/docker/nzbToMedia/core/__init__.py", line 52, in <module>
    from core import logger, main_db, version_check, databases, transcoder
  File "/volume1/docker/nzbToMedia/core/logger.py", line 10, in <module>
    import logging
ModuleNotFoundError: No module named 'logging'
clinton-hall commented 1 year ago

it looks like your python is missing logging.

you will need to install logging (within your docker?) using 'pip install logging'

MrCee commented 1 year ago

The thing is, I've found the great way to have your script alongside every docker container, and although the nzbToMedia folder is simply a git clone, every docker container reaches in and uses it seamlessly without the need to adjust docker containers. Can we add logging to your script instead?

I don't build a fancy docker container with extra parameters, willing to try... but if there is a way for you to ensure logging will work with your script without changing a container that would be great.

I am used to running your scripts and they work on all containers. Previously, there was much API work you and I put into TorrentToMedia.py for Synology Download Station where you could only go by the information I found theoretically. A great result was achieved. Download Station on Synology is not a docker container... so maybe we SHOULD include 'logging' in your script?

labrys commented 1 year ago

@MrCee logging is built in to Python. If logging isn't available its likely because the system has explicitly removed it from Python or is otherwise preventing it from importing. Its more of a problem with the configuration of the system and trying to include logging within nzbToMedia could cause issues for other users that are properly configured. Could you provide more information about the docker containers that you are using?

MrCee commented 1 year ago

The docker containers I used are:

linuxserver/sabnzbd linuxserver/radarr:latest

with the current config each container reaches in to the nzbToMedia folder easily. Below is an example where I specify the internal path is the same as the external path in the docker-compose.yml My nzbToMedia folder sits alongside all docker containers and reaching into this folder is very straight forward when you set the exact same path externally and internally. Everything just works. Until this logging issue. Note: Python 3.10.5 is now the default on Synology NAS.

    volumes:
    - /volume1/docker/nzbToMedia:/volume1/docker/nzbToMedia

Full docker-compose.yml...

version: "3.9"

services:
  sabnzbd:
    container_name: sabnzbd
    image: linuxserver/sabnzbd
    environment:
    - PUID=[YOUR PUID]
    - PGID=[YOUR PGID]
    - TZ=[YOUR TIMEZONE]
    volumes:
    - /volume1/docker/sabnzbd/config:/config
    - /volume1/docker/nzbToMedia:/volume1/docker/nzbToMedia
    - /volume1/downloads:/volume1/downloads
    - /volume1/docker/sabnzbd/config/90-config:/etc/cont-init.d/90-config
    ports:
    - [YOUR PORT]:[YOUR PORT]
    network_mode: [YOUR BRIDGE]
    restart: unless-stopped
MrCee commented 1 year ago

Fixed issue by removing /opt/bin/python & /opt/bin/git and re-installing python and git using Synology Package Manager, and updating autoProcessMedia.cfg for correct path of git.

Received this message and ran the command as requested. All works again.

fatal: detected dubious ownership in repository at '/volume1/docker/nzbToMedia'
To add an exception for this directory, call:

    git config --global --add safe.directory /volume1/docker/nzbToMedia
MrCee commented 1 year ago

After a DSM re-install, I faced the same issue again and came back to this post to see how I resolved it last time. Not entirely happy with my own previous workaround solution above, I thought I would look further into fixing the opkg version of python without installing from the Synology Package Centre.

All I needed to do was install pip after python...

opkg install python3
opkg install python3-pip