doonze / EmbyUpdate

A python script for automatically updating Emby to the latest version on Linux distros.
GNU Lesser General Public License v3.0
15 stars 3 forks source link

Python Errors on Fedora Server 39/Python 3.12 #21

Open agottschling opened 5 months ago

agottschling commented 5 months ago

Noticed my emby server was down right around the time that 4.8 came out, took a look at the logs for EmbyUpdate in SystemD and found this. Any ideas?

Feb 03 15:37:40 Iceland systemd[1]: Starting embyupdate.service - EmbyUpdater...
Feb 03 15:37:41 Iceland sudo[390347]:     root : PWD=/root/EmbyUpdate ; USER=*** ; COMMAND=/usr/sbin/service emby-server stop
Feb 03 15:37:41 Iceland sudo[390347]: pam_unix(sudo:session): session opened for user ***
Feb 03 15:37:41 Iceland sudo[390347]: pam_unix(sudo:session): session closed for user ***
Feb 03 15:37:41 Iceland sudo[390347]: PAM Attempted to close sd-bus after fork, this should not happen.
Feb 03 15:37:44 Iceland python3[390346]: [Feb 03 2024 - 03:37:40 PM] EmbyUpdate(self): App is up to date!  Current and Online versions are at v4.20 - Stable. Continuing...
Feb 03 15:37:44 Iceland python3[390346]: [Feb 03 2024 - 03:37:40 PM] We were unable to connect to a running instance of Emby Server. If it's running, try running the config updater to check settings.
Feb 03 15:37:44 Iceland python3[390346]: [Feb 03 2024 - 03:37:41 PM] EmbyUpdate: Most recent online version is 4.8.0.80 - Stable and current installed version is 4.7.14.0 - Stable for server gStream. We're >
Feb 03 15:37:44 Iceland python3[390346]: [Feb 03 2024 - 03:37:41 PM] EmbyUpdate: Starting update......
Feb 03 15:37:44 Iceland python3[390346]: [Feb 03 2024 - 03:37:41 PM] Stopping Emby server.....
Feb 03 15:37:44 Iceland python3[390346]: [Feb 03 2024 - 03:37:44 PM] Emby Server Stopped...
Feb 03 15:37:44 Iceland python3[390346]: [Feb 03 2024 - 03:37:44 PM] Starting Package download... Please wait, this can take several minutes.
Feb 03 15:37:44 Iceland python3[390346]: *** EmbyUpdate: Something went wrong on the update/install.
Feb 03 15:37:44 Iceland python3[390346]: Traceback (most recent call last):
Feb 03 15:37:44 Iceland python3[390346]:   File "/root/EmbyUpdate/functions/install.py", line 64, in update_emby
Feb 03 15:37:44 Iceland python3[390346]:     download = requests.get(download_url)
Feb 03 15:37:44 Iceland python3[390346]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 03 15:37:44 Iceland python3[390346]:   File "/usr/lib/python3.12/site-packages/requests/api.py", line 73, in get
Feb 03 15:37:44 Iceland python3[390346]:     return request("get", url, params=params, **kwargs)
Feb 03 15:37:44 Iceland python3[390346]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 03 15:37:44 Iceland python3[390346]:   File "/usr/lib/python3.12/site-packages/requests/api.py", line 59, in request
Feb 03 15:37:44 Iceland python3[390346]:     return session.request(method=method, url=url, **kwargs)
Feb 03 15:37:44 Iceland python3[390346]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 03 15:37:44 Iceland python3[390346]:   File "/usr/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
Feb 03 15:37:44 Iceland python3[390346]:     resp = self.send(prep, **send_kwargs)
Feb 03 15:37:44 Iceland python3[390346]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 03 15:37:44 Iceland python3[390346]:   File "/usr/lib/python3.12/site-packages/requests/sessions.py", line 697, in send
Feb 03 15:37:44 Iceland python3[390346]:     adapter = self.get_adapter(url=request.url)
Feb 03 15:37:44 Iceland python3[390346]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 03 15:37:44 Iceland python3[390346]:   File "/usr/lib/python3.12/site-packages/requests/sessions.py", line 794, in get_adapter
Feb 03 15:37:44 Iceland python3[390346]:     raise InvalidSchema(f"No connection adapters were found for {url!r}")
Feb 03 15:37:44 Iceland python3[390346]: requests.exceptions.InvalidSchema: No connection adapters were found for 'sudo dnf -y install https://github.com/MediaBrowser/Emby.Releases/releases/download/4.8.0.8>
Feb 03 15:37:45 Iceland systemd[1]: embyupdate.service: Deactivated successfully.
Feb 03 15:37:45 Iceland systemd[1]: Finished embyupdate.service - EmbyUpdater.
doonze commented 4 months ago

Not at this time. that's a new one for me. I'll look into it more later and see if I can figure out what it's choking on. First guess is that the URL has changed on Emby GitHub side. Or maybe that they hadn't gotten the file out there yet. But the InvalidSchema error has me unsure.

agottschling commented 4 months ago

UPDATE: I had the same issue with the 4.8.1 upgrade that came out recently. Noticed my server was down yesterday and had very similar error logs

doonze commented 4 months ago

My Debian instance updated fine without errors to 4.8 and 4.8.1. This seems specific to Fedora. I'm not SURE you have to stop and start the server with Fedora, as I've not had a Fedora instance to test on. It was a best guess on my part based on research I had done. I never found a definite answer. Just to let you know I am looking into this. I've had COVID since Wednesday so I've been under the weather. I'll update if I find anything.

Let me add to that. The update would still fail either way, but your server wouldn't be down. It might be better for it to go down, as that way you know the update failed. If this happened on Debain, the only way to know is to notice Emby was saying there was an update needed or to notice errors in the log. I could create an email process to alert if there are failures. But I hadn't written that yet.

doonze commented 4 months ago

@agottschling what version are you using of EmbyUpdate? You can find it in the code itself (inside embyupdate.py) at version = "v4.20" for example, or issue ./embyupdate.py -v on the command line from the directory embyupdate is in.

I'm pretty sure the problem is this "https://github.com/MediaBrowser/Emby.Releases/releases/download/4.8.0.8" as that is not the correct URL. It should be "https://github.com/MediaBrowser/Emby.Releases/releases/download/4.8.0.8/emby-server-rpm_4.8.0.8_x86_64.rpm" your version seems to be dropping everything after the first 4.8.0.8. This is built dynamically, so SHOULD impact ALL distro's if it's a problem, but I know Debian is working fine.

Still digging.

doonze commented 4 months ago

I have a fix. The problem is a bug from me not having a non-debian install to test on. Mostly I put the right command in the wrong place in the database. So it doesn't try and run the command on other distro's, but instead tries to download it, like it would in Debian. I wrote all the new code in a few all nighters, and didn't think it through well enough. I'm also not writing the code fix right now, due to my COVID, as I'm not thinking clear enough to release a new version with the fix. I want to vett out my thinking more before I do.

Anyway, to fix it for now you can do the following:

From where you have embyupdate installed issue: ./embyupdate.py -cd distro edit in terminal.

All the distro's should come up. Reply 5 to the prompt to edit Fedora.

Copy what's in "downloadurl", and then Enter 2 at the prompt and paste in what you copied in the last step. Hit enter. It will ask if you want to edit more, say yes.

Enter 5 again to edit Fedora, and this time select 1. Enter "notused" and hit enter. It will ask again if you want to edit more, say yes.

5 again, and this time edit 3 and update it to "used" and hit enter. When it asks, say yes you want to edit more.

One last time, go into 5 and make sure it looks like the below now. If it doesn't, update it till it does. If it does you can just cancel out of the edit mode.

[1] downloadurl     : notused
[2] installcommand  : sudo dnf -y install https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_x86_64.rpm
[3] installfile     : used

In my testing it will start working right now. My Debain of course chokes on DNF because it doesn't exist on Debain. But it does correctly try to issue the command. I'll get the problem fixed in the stable version after we verify this is working.

Testing it before the next update is a pain, because if the the server is running, it will query the Emby server for what version it's on, and if there is no update needed, it will not try to update. You COULD bring your Emby server instance down, then issue ./embyupdate.py -cd emby edit, and update the version to 0. If you manually run embyupdate ./embyupdate.py You should be able to see if it runs correctly. It will either reinstall the latest Emby, or if it works like Debian it will simply tell you that you already have the lastest version.

I also discovered it throws a bunch of exceptions now if the server is down. Not sure if there was a Python update, or if I added more error displays that now show those exceptions (when I was writing it, it didn't throw those during testing since I handled them). I handle them in code, so embyupdate keeps running, but it's just chatter that's not needed. In fact, it's the exception I use to know if your emby server is up or not. No exception, it's up and we use its response. Exception, we use the last known good install in the database if there is one. When I'm feeling better I'm also going to silence that. Unsure what I did to start displaying it, and don't feel well enough to dig into it ATM. LOL

agottschling commented 2 months ago

Sorry this took me so long, but I finally applied that fix. Seems to be working now, but I'll know for sure with the next patch of emby.

doonze commented 2 months ago

I still haven't fixed this in upstream. I've been playing catch-up being out so long with COVID. And I want to verify it's working before I roll any updates.

Keep me posted.

agottschling commented 1 month ago

Whelp, Hit another error when attempting to upgrade this time. Logs below:

May 20 10:26:06 Iceland python3[629133]: [May 20 2024 - 10:26:06 AM] EmbyUpdate: Starting update...... May 20 10:26:06 Iceland python3[629133]: *** EmbyUpdate: Something went wrong on the update/install. May 20 10:26:06 Iceland python3[629133]: Traceback (most recent call last): May 20 10:26:06 Iceland python3[629133]: File "/root/EmbyUpdate/functions/install.py", line 40, in update_emby May 20 10:26:06 Iceland python3[629133]: install_command = distro_config.installcommand.format(install_file=distro_config.installfile. May 20 10:26:06 Iceland python3[629133]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ May 20 10:26:06 Iceland python3[629133]: KeyError: 'online_version' May 20 10:26:06 Iceland systemd[1]: embyupdate.service: Deactivated successfully. May 20 10:26:06 Iceland systemd[1]: Finished embyupdate.service - EmbyUpdater.

[root@Iceland EmbyUpdate]# ./embyupdate.py -cd distroconfig

DistroConfig:

[1] Debian X64:

downloadurl : https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/{install_file} installcommand : sudo dpkg -i -E {installfile} installfile : emby-server-deb{online_version}_amd64.deb

[2] Debian ARM:

downloadurl : https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/{install_file} installcommand : dpkg -i {installfile} installfile : emby-server-deb{online_version}_armhf.deb

[3] Arch:

downloadurl : notused installcommand : sudo pacman -S emby-server installfile : notused

[4] CentOS:

downloadurl : sudo yum --y install https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_x86_64.rpm installcommand : notused installfile : notused

[5] Fedora X64:

downloadurl : notused installcommand : sudo dnf -y install https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_x86_64.rpm installfile : used

[6] Fedora ARM:

downloadurl : sudo dnf -y install https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_aarch64.rpm installcommand : notused installfile : notused

[7] OpenSUSE X64:

downloadurl : sudo zypper install https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_x86_64.rpm installcommand : notused installfile : notused

[8] OpenSUSE ARM:

downloadurl : sudo zypper install -y https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_aarch64.rpm installcommand : notused installfile : notused

agottschling commented 1 month ago

Whelp, looks like we might have a flag on the play. Logs below:

3:35 AM Finished embyupdate.service - EmbyUpdater. systemd 3:35 AM embyupdate.service: Deactivated successfully. systemd 3:35 AM KeyError: 'online_version' python3 3:35 AM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ python3 3:35 AM install_command = distro_config.installcommand.format(install_file=distro_config.installfile. python3 3:35 AM File "/root/EmbyUpdate/functions/install.py", line 40, in update_emby python3 3:35 AM Traceback (most recent call last): python3 3:35 AM *** EmbyUpdate: Something went wrong on the update/install. python3 3:35 AM [May 21 2024 - 03:35:37 AM] EmbyUpdate: Starting update...... python3 3:35 AM [May 21 2024 - 03:35:37 AM] EmbyUpdate: Most recent online version is 4.8.7.0 - Stable and current installed version is 4.8.5.0 - Stable for server gStream. We're updating Emby. python3 3:35 AM [May 21 2024 - 03:35:36 AM] EmbyUpdate(self): App is up to date! Current and Online versions are at v4.20 - Stable. Continuing... python3 3:35 AM Starting embyupdate.service - EmbyUpdater... systemd

DistroConfig:

[1] Debian X64:

downloadurl : https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/{install_file} installcommand : sudo dpkg -i -E {installfile} installfile : emby-server-deb{online_version}_amd64.deb

[2] Debian ARM:

downloadurl : https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/{install_file} installcommand : dpkg -i {installfile} installfile : emby-server-deb{online_version}_armhf.deb

[3] Arch:

downloadurl : notused installcommand : sudo pacman -S emby-server installfile : notused

[4] CentOS:

downloadurl : sudo yum --y install https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_x86_64.rpm installcommand : notused installfile : notused

[5] Fedora X64:

downloadurl : notused installcommand : sudo dnf -y install https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_x86_64.rpm installfile : used

[6] Fedora ARM:

downloadurl : sudo dnf -y install https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_aarch64.rpm installcommand : notused installfile : notused

[7] OpenSUSE X64:

downloadurl : sudo zypper install https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_x86_64.rpm installcommand : notused installfile : notused

[8] OpenSUSE ARM:

downloadurl : sudo zypper install -y https://github.com/MediaBrowser/Emby.Releases/releases/download/{online_version}/emby-server-rpm_{online_version}_aarch64.rpm installcommand : notused installfile : notused

root@Iceland:~/EmbyUpdate#

doonze commented 1 month ago

ok, thanks for the reports. I understand the error it's getting, just not why. Here is the code in question: install_command = distro_config.installcommand.format(install_file=distro_config.installfile. format(online_version=configobj.onlineversion))

Thing is online_version has no key errors in the statements before this line. I'll have to dig into it when I get some time. But I'm wondering if that . (period) at the end of the first line should instead be a , (comma)? I'm also not sure why I'm not getting the error as well.

doonze commented 1 month ago

You can try changing that line 40 in install.py, and see if that fixes it.

agottschling commented 1 month ago

Interesting, now I'm getting the following:

May 22 10:57:42 Iceland python3[36359]: Traceback (most recent call last): May 22 10:57:42 Iceland python3[36359]: File "/root/EmbyUpdate/embyupdate.py", line 109, in May 22 10:57:42 Iceland python3[36359]: main() May 22 10:57:42 Iceland python3[36359]: File "/root/EmbyUpdate/embyupdate.py", line 60, in main May 22 10:57:42 Iceland python3[36359]: c = colors.Terminalcolors() May 22 10:57:42 Iceland python3[36359]: ^^^^^^ May 22 10:57:42 Iceland python3[36359]: NameError: name 'colors' is not defined May 22 10:57:42 Iceland systemd[1]: embyupdate.service: Main process exited, code=exited, status=1/FAILURE May 22 10:57:42 Iceland systemd[1]: embyupdate.service: Failed with result 'exit-code'.

EDIT: flipping it back to a period returned me to the prior error

doonze commented 1 month ago

What version of Python are you running?

On Wed, May 22, 2024, 9:58 AM Andrew Gottschling @.***> wrote:

Interesting, now I'm getting the following:

May 22 10:57:42 Iceland python3[36359]: Traceback (most recent call last): May 22 10:57:42 Iceland python3[36359]: File "/root/EmbyUpdate/embyupdate.py", line 109, in May 22 10:57:42 Iceland python3[36359]: main() May 22 10:57:42 Iceland python3[36359]: File "/root/EmbyUpdate/embyupdate.py", line 60, in main May 22 10:57:42 Iceland python3[36359]: c = colors.Terminalcolors() May 22 10:57:42 Iceland python3[36359]: ^^^^^^ May 22 10:57:42 Iceland python3[36359]: NameError: name 'colors' is not defined May 22 10:57:42 Iceland systemd[1]: embyupdate.service: Main process exited, code=exited, status=1/FAILURE May 22 10:57:42 Iceland systemd[1]: embyupdate.service: Failed with result 'exit-code'.

— Reply to this email directly, view it on GitHub https://github.com/doonze/EmbyUpdate/issues/21#issuecomment-2125019029, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF6BHW65S7MRXK2QY3DDLQ3ZDSXDBAVCNFSM6AAAAABCYJDEE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRVGAYTSMBSHE . You are receiving this because you commented.Message ID: @.***>

agottschling commented 1 month ago

Latest available for Fedora 40. Seems to be 3.12.3

Welcome to fish, the friendly interactive shell Type help for instructions on how to use fish agottschling@Iceland ~> python --version Python 3.12.3 agottschling@Iceland ~> python3 --version Python 3.12.3 agottschling@Iceland ~>

doonze commented 1 month ago

I haven't tested on 3.11. I developed on a Mint box (Debian base) that upstream is 3.11. They may have changed something (3.11 broke a bunch of stuff I had to fix).

On Thu, May 23, 2024 at 7:26 AM Andrew Gottschling @.***> wrote:

Latest available for Fedora 40. Seems to be 3.12.3

Welcome to fish, the friendly interactive shell Type help for instructions on how to use fish @. ~> python --version Python 3.12.3 @. ~> python3 --version Python 3.12.3 @.*** ~>

— Reply to this email directly, view it on GitHub https://github.com/doonze/EmbyUpdate/issues/21#issuecomment-2126980995, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF6BHW7LV7236OGRRETYXFTZDXN6VAVCNFSM6AAAAABCYJDEE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRWHE4DAOJZGU . You are receiving this because you commented.Message ID: @.***>