Mailing List Archive

find_orphans.py not working as expected
Hello all,

During this extended period of physical distancing, I decided to rebuild
my MythTV system. Overall it was a fairly smooth process and I'm now
running MythTV 31 (installed from the RPM Fusion repo) on Fedora 31.
Everything seems to be working as expected except for find_orphans.py.
On my previous system I was using the old myth.find_orphans.pl so this
is my first experience with find_orphans.py. My ultimate goal is to
schedule find_orphans.py to run on a regular basis so that it will send
an email if it encounters any issues.

I've copied the code from https://www.mythtv.org/wiki/Find_orphans.py
(find_orphans.py (for v31+)) and it runs but the results are a little
confusing. Basically find_orphans.py returns every single recording as
"Recordings with missing files".

$ ./find_orphans.py
Recordings with missing files
...
? odysseus: Saturday Night Live - SNL At
Home??????????????????????????????? 10201_20200510032700.ts
...
Count:???????? 127
Please select from the following
?1. Delete orphaned recording entries
?2. Refresh list
>

I can confirm that the relevant files are in the recordings directory
(e.g., 10201_20200510032700.ts). I can see and play the recording via
mythfrontend as well as mythweb. Everything seems to be in order except
for the find_orphans.py output.

Is anyone else having issues with find_orphans.py? I'm not proficient
with Python so looking for any tips, tricks, or guidance on how to get
find_orphans.py working.

Thanks!
Gary
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 5/13/20 12:58 PM, Gary Raposo wrote:
> Hello all,
>
> During this extended period of physical distancing, I decided to rebuild my MythTV system. Overall it was a fairly smooth process and I'm now
> running MythTV 31 (installed from the RPM Fusion repo) on Fedora 31. Everything seems to be working as expected except for find_orphans.py. On
> my previous system I was using the old myth.find_orphans.pl so this is my first experience with find_orphans.py. My ultimate goal is to schedule
> find_orphans.py to run on a regular basis so that it will send an email if it encounters any issues.
>
> I've copied the code from https://www.mythtv.org/wiki/Find_orphans.py (find_orphans.py (for v31+)) and it runs but the results are a little
> confusing. Basically find_orphans.py returns every single recording as "Recordings with missing files".
>
> $ ./find_orphans.py
> Recordings with missing files
> ...
> ? odysseus: Saturday Night Live - SNL At Home??????????????????????????????? 10201_20200510032700.ts
> ...
> Count:???????? 127
> Please select from the following
> ?1. Delete orphaned recording entries
> ?2. Refresh list
> >
>
> I can confirm that the relevant files are in the recordings directory (e.g., 10201_20200510032700.ts). I can see and play the recording via
> mythfrontend as well as mythweb. Everything seems to be in order except for the find_orphans.py output.
>
> Is anyone else having issues with find_orphans.py? I'm not proficient with Python so looking for any tips, tricks, or guidance on how to get
> find_orphans.py working.

"Works for me". Begin guess mode.

New host (and/or new hostname)? What do these return:

curl --header 'Accept:application/json' localhost:6544/Myth/GetHostName
hostname

As to scheduling, the program is interactive (so you must say yes to things to be deleted.)

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 2020-05-13 2:30 p.m., Bill Meek wrote:
> On 5/13/20 12:58 PM, Gary Raposo wrote:
>> Hello all,
>>
>> During this extended period of physical distancing, I decided to
>> rebuild my MythTV system. Overall it was a fairly smooth process and
>> I'm now running MythTV 31 (installed from the RPM Fusion repo) on
>> Fedora 31. Everything seems to be working as expected except for
>> find_orphans.py. On my previous system I was using the old
>> myth.find_orphans.pl so this is my first experience with
>> find_orphans.py. My ultimate goal is to schedule find_orphans.py to
>> run on a regular basis so that it will send an email if it encounters
>> any issues.
>>
>> I've copied the code from https://www.mythtv.org/wiki/Find_orphans.py
>> (find_orphans.py (for v31+)) and it runs but the results are a little
>> confusing. Basically find_orphans.py returns every single recording
>> as "Recordings with missing files".
>>
>> $ ./find_orphans.py
>> Recordings with missing files
>> ...
>> ?? odysseus: Saturday Night Live - SNL At
>> Home??????????????????????????????? 10201_20200510032700.ts
>> ...
>> Count:???????? 127
>> Please select from the following
>> ??1. Delete orphaned recording entries
>> ??2. Refresh list
>> ?>
>>
>> I can confirm that the relevant files are in the recordings directory
>> (e.g., 10201_20200510032700.ts). I can see and play the recording via
>> mythfrontend as well as mythweb. Everything seems to be in order
>> except for the find_orphans.py output.
>>
>> Is anyone else having issues with find_orphans.py? I'm not proficient
>> with Python so looking for any tips, tricks, or guidance on how to
>> get find_orphans.py working.
>
> "Works for me". Begin guess mode.
>
> New host (and/or new hostname)? What do these return:
>
> ? curl --header 'Accept:application/json' localhost:6544/Myth/GetHostName
> ? hostname
>
> As to scheduling, the program is interactive (so you must say yes to
> things to be deleted.)
>
Good point about the interactive model. I may have to rethink the
scheduling bit. I'd still like to be able to run find_orphans.py
manually at the very least.

The output of those commands look good:

$ curl --header 'Accept:application/json' localhost:6544/Myth/GetHostName
{"String": "odysseus"}
$ hostname
odysseus

Gary
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 2020-05-13 4:21 p.m., Gary Raposo wrote:
> On 2020-05-13 2:30 p.m., Bill Meek wrote:
>> On 5/13/20 12:58 PM, Gary Raposo wrote:
>>> Hello all,
>>>
>>> During this extended period of physical distancing, I decided to
>>> rebuild my MythTV system. Overall it was a fairly smooth process and
>>> I'm now running MythTV 31 (installed from the RPM Fusion repo) on
>>> Fedora 31. Everything seems to be working as expected except for
>>> find_orphans.py. On my previous system I was using the old
>>> myth.find_orphans.pl so this is my first experience with
>>> find_orphans.py. My ultimate goal is to schedule find_orphans.py to
>>> run on a regular basis so that it will send an email if it
>>> encounters any issues.
>>>
>>> I've copied the code from
>>> https://www.mythtv.org/wiki/Find_orphans.py (find_orphans.py (for
>>> v31+)) and it runs but the results are a little confusing. Basically
>>> find_orphans.py returns every single recording as "Recordings with
>>> missing files".
>>>
>>> $ ./find_orphans.py
>>> Recordings with missing files
>>> ...
>>> ?? odysseus: Saturday Night Live - SNL At
>>> Home??????????????????????????????? 10201_20200510032700.ts
>>> ...
>>> Count:???????? 127
>>> Please select from the following
>>> ??1. Delete orphaned recording entries
>>> ??2. Refresh list
>>> ?>
>>>
>>> I can confirm that the relevant files are in the recordings
>>> directory (e.g., 10201_20200510032700.ts). I can see and play the
>>> recording via mythfrontend as well as mythweb. Everything seems to
>>> be in order except for the find_orphans.py output.
>>>
>>> Is anyone else having issues with find_orphans.py? I'm not
>>> proficient with Python so looking for any tips, tricks, or guidance
>>> on how to get find_orphans.py working.
>>
>> "Works for me". Begin guess mode.
>>
>> New host (and/or new hostname)? What do these return:
>>
>> ? curl --header 'Accept:application/json'
>> localhost:6544/Myth/GetHostName
>> ? hostname
>>
>> As to scheduling, the program is interactive (so you must say yes to
>> things to be deleted.)
>>
> Good point about the interactive model. I may have to rethink the
> scheduling bit. I'd still like to be able to run find_orphans.py
> manually at the very least.
>
> The output of those commands look good:
>
> $ curl --header 'Accept:application/json' localhost:6544/Myth/GetHostName
> {"String": "odysseus"}
> $ hostname
> odysseus
>
> Gary
Quick update.

I managed to get a few print statements into the code and from what I
can tell it looks like "host" is being set to "None" in "populate". As a
result, nothing is added to "unfiltered".

"recs" is being populated correctly with all of the files from the
recorded table but because "unfiltered" is empty, all of the recordings
are listed as "Recordings with missing files".

As I mentioned earlier, I'm not a Python expert so I'm not sure if I'm
following the logic in the code correctly. Is it normal for "host" to be
set to "None"?

It also looks like I should be able to specify the hostname on the
command line but every time I try to add an argument to find_orphans.py
it fails with: Exception: Invalid hostname specified on command line.

Does anyone know what a valid command line with arguments looks like?

Thanks
Gary
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 5/14/20 3:19 PM, Gary Raposo wrote:
...

> Quick update.
>
> I managed to get a few print statements into the code and from what I can tell it looks like "host" is being set to "None" in "populate". As a
> result, nothing is added to "unfiltered".
>
> "recs" is being populated correctly with all of the files from the recorded table but because "unfiltered" is empty, all of the recordings are
> listed as "Recordings with missing files".
>
> As I mentioned earlier, I'm not a Python expert so I'm not sure if I'm following the logic in the code correctly. Is it normal for "host" to be
> set to "None"?
>
> It also looks like I should be able to specify the hostname on the command line but every time I try to add an argument to find_orphans.py it
> fails with: Exception: Invalid hostname specified on command line.
>
> Does anyone know what a valid command line with arguments looks like?

Running without the host is OK. I suspect that if this is a new box
BackendServerIP isn't in settings. I'd try changing it to MasterServerIP

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 5/14/20 3:19 PM, Gary Raposo wrote:
...

If I have a host value that doesn't match my recordings, then I get all
recordings showing up as missing.

Try printing the hosts value like this:

else:
with DB as c:
c.execute("""SELECT hostname FROM settings
WHERE value='BackendServerIP'""")
hosts = [r[0] for r in c.fetchall()]
print('hosts=',hosts) # <---------------------------

Look at some recordings. Press 'i' twice and see what the value of
Recording Host: is set to.

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 2020-05-14 5:09 p.m., Bill Meek wrote:
> On 5/14/20 3:19 PM, Gary Raposo wrote:
> ...
>
> If I have a host value that doesn't match my recordings, then I get all
> recordings showing up as missing.
>
> Try printing the hosts value like this:
>
> ??? else:
> ??????? with DB as c:
> ??????????? c.execute("""SELECT hostname FROM settings
> ???????????????????????? WHERE value='BackendServerIP'""")
> ??????????? hosts = [r[0] for r in c.fetchall()]
> ??????????? print('hosts=',hosts) # <---------------------------
>
> Look at some recordings. Press 'i' twice and see what the value of
> Recording Host: is set to.
>

Thanks for the suggestions, Bill. Still no luck.

I checked the settings table and I do not have an entry for
BackendServerIP. I do have a valid/correct entry for MasterServerIP so
changed the code to reference MasterServerIP. No change.

If I add the print statement you suggested, it's still showing None:
hosts= [None]

Checking my recordings (pressing "i" twice) I can see that they are all
correctly tagged with odysseus as the hostname. MasterServerIP
references the correct IP address for odysseus and /etc/hosts matches.

Looking at the query, it looks like they are pulling hostname from the
settings table for the entry associated with the
BackendServerIP/MasterServerIP. I hadn't really looked at it that
closely before and assumed they were pulling the hostname based on the
data field. Wouldn't you know it, hostname is set to NULL for that entry.

I updated the settings table and set hostname = odysseus for
MasterServerIP + added an entry for BackendServerIP (just in case) and
now I've moved on to a whole different set of problems!

Before, I was able to see all my recordings but they were listed as
"Recordings with missing files". Now I get no output and the following
errors:

$ ./find_orphans.py
Traceback (most recent call last):
? File "./find_orphans.py", line 222, in <module>
??? BE = MythBE(db=DB)
? File "/usr/lib/python3.7/site-packages/MythTV/mythproto.py", line 80,
in __init__
??? self.hostname = self.db._gethostfromaddr(self.host)
? File "/usr/lib/python3.7/site-packages/MythTV/database.py", line
1348, in _gethostfromaddr
??? 'BackendServerAddr', addr)
MythTV.exceptions.MythDBError: Could not find setting
'BackendServerAddr' on host 'None'

Not too sure what's going on. Looking at the settings table, I have
three entries: BackendServerIP, MasterServerIP, and BackendServerAddr.
All have data set to 10.10.10.20 and hostname = odysseus.

I'm poking around now in mythproto.py and database.py but (again) my
lack of Python experience is making this a slow process.

As always, any suggestions are welcome.

Gary

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On Fri, May 15, 2020 at 3:43 PM Gary Raposo <gary@raposo.ca> wrote:
>
> On 2020-05-14 5:09 p.m., Bill Meek wrote:
> > On 5/14/20 3:19 PM, Gary Raposo wrote:
> > ...
> >
> > If I have a host value that doesn't match my recordings, then I get all
> > recordings showing up as missing.
> >
> > Try printing the hosts value like this:
> >
> > else:
> > with DB as c:
> > c.execute("""SELECT hostname FROM settings
> > WHERE value='BackendServerIP'""")
> > hosts = [r[0] for r in c.fetchall()]
> > print('hosts=',hosts) # <---------------------------
> >
> > Look at some recordings. Press 'i' twice and see what the value of
> > Recording Host: is set to.
> >
>
> Thanks for the suggestions, Bill. Still no luck.
>
> I checked the settings table and I do not have an entry for
> BackendServerIP. I do have a valid/correct entry for MasterServerIP so
> changed the code to reference MasterServerIP. No change.
>
> If I add the print statement you suggested, it's still showing None:
> hosts= [None]
>
> Checking my recordings (pressing "i" twice) I can see that they are all
> correctly tagged with odysseus as the hostname. MasterServerIP
> references the correct IP address for odysseus and /etc/hosts matches.
>
> Looking at the query, it looks like they are pulling hostname from the
> settings table for the entry associated with the
> BackendServerIP/MasterServerIP. I hadn't really looked at it that
> closely before and assumed they were pulling the hostname based on the
> data field. Wouldn't you know it, hostname is set to NULL for that entry.
>
> I updated the settings table and set hostname = odysseus for
> MasterServerIP + added an entry for BackendServerIP (just in case) and
> now I've moved on to a whole different set of problems!
>
> Before, I was able to see all my recordings but they were listed as
> "Recordings with missing files". Now I get no output and the following
> errors:
>
> $ ./find_orphans.py
> Traceback (most recent call last):
> File "./find_orphans.py", line 222, in <module>
> BE = MythBE(db=DB)
> File "/usr/lib/python3.7/site-packages/MythTV/mythproto.py", line 80,
> in __init__
> self.hostname = self.db._gethostfromaddr(self.host)
> File "/usr/lib/python3.7/site-packages/MythTV/database.py", line
> 1348, in _gethostfromaddr
> 'BackendServerAddr', addr)
> MythTV.exceptions.MythDBError: Could not find setting
> 'BackendServerAddr' on host 'None'
>
> Not too sure what's going on. Looking at the settings table, I have
> three entries: BackendServerIP, MasterServerIP, and BackendServerAddr.
> All have data set to 10.10.10.20 and hostname = odysseus.
>
> I'm poking around now in mythproto.py and database.py but (again) my
> lack of Python experience is making this a slow process.
>
> As always, any suggestions are welcome.
>
> Gary


Gary
MythTV v29 changed the behaviour for
'BackendServerAddr', 'BackendServerIP', 'BackendServerIP6'
as described in ticket https://code.mythtv.org/trac/ticket/13024.

In short:
If someone explicitly wants a 'BackendServerIP' or 'BackendServerIP6'
this must be entered in the database during the setup step.
But 'BackendServerAddr' should be always in the database for each backend.

The script 'find_orphans.py' iterates over all backends, therefore
I kindly ask you to change every occurrence of
'BackendServerIP' to 'BackendServerAddr' in this script and try again.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 5/15/20 12:51 PM, Roland Ernst wrote:

...

> Gary
> MythTV v29 changed the behaviour for
> 'BackendServerAddr', 'BackendServerIP', 'BackendServerIP6'
> as described in ticket https://code.mythtv.org/trac/ticket/13024.
>
> In short:
> If someone explicitly wants a 'BackendServerIP' or 'BackendServerIP6'
> this must be entered in the database during the setup step.
> But 'BackendServerAddr' should be always in the database for each backend.
>
> The script 'find_orphans.py' iterates over all backends, therefore
> I kindly ask you to change every occurrence of
> 'BackendServerIP' to 'BackendServerAddr' in this script and try again.

If that's done via mysql, don't forget to run: mythutil --clearcache
after the changes.

--
Bill
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On Fri, May 15, 2020 at 8:14 PM Bill Meek <keemllib@gmail.com> wrote:

> On 5/15/20 12:51 PM, Roland Ernst wrote:
>
> ...
>
> > Gary
> > MythTV v29 changed the behaviour for
> > 'BackendServerAddr', 'BackendServerIP', 'BackendServerIP6'
> > as described in ticket https://code.mythtv.org/trac/ticket/13024.
> >
> > In short:
> > If someone explicitly wants a 'BackendServerIP' or 'BackendServerIP6'
> > this must be entered in the database during the setup step.
> > But 'BackendServerAddr' should be always in the database for each
> backend.
> >
> > The script 'find_orphans.py' iterates over all backends, therefore
> > I kindly ask you to change every occurrence of
> > 'BackendServerIP' to 'BackendServerAddr' in this script and try again.
>
> If that's done via mysql, don't forget to run: mythutil --clearcache
> after the changes.
>
> --
> Bill
>
>

And, please post the output of


select * from settings where value like 'BackendServer%';
>

and

select * from settings where value like 'Master%';
>
Re: find_orphans.py not working as expected [ In reply to ]
On 5/15/20 9:41 AM, Gary Raposo wrote:
> On 2020-05-14 5:09 p.m., Bill Meek wrote:
>> On 5/14/20 3:19 PM, Gary Raposo wrote:
>> ...
>>
>> If I have a host value that doesn't match my recordings, then I get all
>> recordings showing up as missing.
>>
>> Try printing the hosts value like this:
>>
>> ??? else:
>> ??????? with DB as c:
>> ??????????? c.execute("""SELECT hostname FROM settings
>> ???????????????????????? WHERE value='BackendServerIP'""")
>> ??????????? hosts = [r[0] for r in c.fetchall()]
>> ??????????? print('hosts=',hosts) # <---------------------------
>>
>> Look at some recordings. Press 'i' twice and see what the value of
>> Recording Host: is set to.
>>
>
> Thanks for the suggestions, Bill. Still no luck.
>
> I checked the settings table and I do not have an entry for
> BackendServerIP. I do have a valid/correct entry for MasterServerIP so
> changed the code to reference MasterServerIP. No change.
>
> If I add the print statement you suggested, it's still showing None:
> hosts= [None]
>
> Checking my recordings (pressing "i" twice) I can see that they are
> all correctly tagged with odysseus as the hostname. MasterServerIP
> references the correct IP address for odysseus and /etc/hosts matches.
>
> Looking at the query, it looks like they are pulling hostname from the
> settings table for the entry associated with the
> BackendServerIP/MasterServerIP. I hadn't really looked at it that
> closely before and assumed they were pulling the hostname based on the
> data field. Wouldn't you know it, hostname is set to NULL for that entry.
>
> I updated the settings table and set hostname = odysseus for
> MasterServerIP + added an entry for BackendServerIP (just in case) and
> now I've moved on to a whole different set of problems!
>
> Before, I was able to see all my recordings but they were listed as
> "Recordings with missing files". Now I get no output and the following
> errors:
>
> $ ./find_orphans.py
> Traceback (most recent call last):
> ? File "./find_orphans.py", line 222, in <module>
> ??? BE = MythBE(db=DB)
> ? File "/usr/lib/python3.7/site-packages/MythTV/mythproto.py", line
> 80, in __init__
> ??? self.hostname = self.db._gethostfromaddr(self.host)
> ? File "/usr/lib/python3.7/site-packages/MythTV/database.py", line
> 1348, in _gethostfromaddr
> ??? 'BackendServerAddr', addr)
> MythTV.exceptions.MythDBError: Could not find setting
> 'BackendServerAddr' on host 'None'
>
> Not too sure what's going on. Looking at the settings table, I have
> three entries: BackendServerIP, MasterServerIP, and BackendServerAddr.
> All have data set to 10.10.10.20 and hostname = odysseus.
>
> I'm poking around now in mythproto.py and database.py but (again) my
> lack of Python experience is making this a slow process.
>
> As always, any suggestions are welcome.

Forgive me if I missed it, but did you try simply:

? ./find_orphans.py odysseus

The script takes one parameter, the host name, as defined in the
settings. To get a list of all the hostnames in use, you can also do:

? echo 'select distinct hostname from mythconverg.settings;' | mysql -u
mythtv -p

This will include frontends.


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 2020-05-15 1:34 p.m., Dan Wilga wrote:
> On 5/15/20 9:41 AM, Gary Raposo wrote:
>> On 2020-05-14 5:09 p.m., Bill Meek wrote:
>>> On 5/14/20 3:19 PM, Gary Raposo wrote:
>>> ...
>>>
>>> If I have a host value that doesn't match my recordings, then I get all
>>> recordings showing up as missing.
>>>
>>> Try printing the hosts value like this:
>>>
>>> ??? else:
>>> ??????? with DB as c:
>>> ??????????? c.execute("""SELECT hostname FROM settings
>>> ???????????????????????? WHERE value='BackendServerIP'""")
>>> ??????????? hosts = [r[0] for r in c.fetchall()]
>>> ??????????? print('hosts=',hosts) # <---------------------------
>>>
>>> Look at some recordings. Press 'i' twice and see what the value of
>>> Recording Host: is set to.
>>>
>>
>> Thanks for the suggestions, Bill. Still no luck.
>>
>> I checked the settings table and I do not have an entry for
>> BackendServerIP. I do have a valid/correct entry for MasterServerIP
>> so changed the code to reference MasterServerIP. No change.
>>
>> If I add the print statement you suggested, it's still showing None:
>> hosts= [None]
>>
>> Checking my recordings (pressing "i" twice) I can see that they are
>> all correctly tagged with odysseus as the hostname. MasterServerIP
>> references the correct IP address for odysseus and /etc/hosts matches.
>>
>> Looking at the query, it looks like they are pulling hostname from
>> the settings table for the entry associated with the
>> BackendServerIP/MasterServerIP. I hadn't really looked at it that
>> closely before and assumed they were pulling the hostname based on
>> the data field. Wouldn't you know it, hostname is set to NULL for
>> that entry.
>>
>> I updated the settings table and set hostname = odysseus for
>> MasterServerIP + added an entry for BackendServerIP (just in case)
>> and now I've moved on to a whole different set of problems!
>>
>> Before, I was able to see all my recordings but they were listed as
>> "Recordings with missing files". Now I get no output and the
>> following errors:
>>
>> $ ./find_orphans.py
>> Traceback (most recent call last):
>> ? File "./find_orphans.py", line 222, in <module>
>> ??? BE = MythBE(db=DB)
>> ? File "/usr/lib/python3.7/site-packages/MythTV/mythproto.py", line
>> 80, in __init__
>> ??? self.hostname = self.db._gethostfromaddr(self.host)
>> ? File "/usr/lib/python3.7/site-packages/MythTV/database.py", line
>> 1348, in _gethostfromaddr
>> ??? 'BackendServerAddr', addr)
>> MythTV.exceptions.MythDBError: Could not find setting
>> 'BackendServerAddr' on host 'None'
>>
>> Not too sure what's going on. Looking at the settings table, I have
>> three entries: BackendServerIP, MasterServerIP, and
>> BackendServerAddr. All have data set to 10.10.10.20 and hostname =
>> odysseus.
>>
>> I'm poking around now in mythproto.py and database.py but (again) my
>> lack of Python experience is making this a slow process.
>>
>> As always, any suggestions are welcome.
>
> Forgive me if I missed it, but did you try simply:
>
> ? ./find_orphans.py odysseus
>
> The script takes one parameter, the host name, as defined in the
> settings. To get a list of all the hostnames in use, you can also do:
>
> ? echo 'select distinct hostname from mythconverg.settings;' | mysql
> -u mythtv -p
>
> This will include frontends.
>

Hi Dan,

In one of the previous updates I mentioned that command line arguments
don't seem to work either. Same error message:

$ ./find_orphans.py odysseus
Traceback (most recent call last):
? File "./find_orphans.py", line 222, in <module>
??? BE = MythBE(db=DB)
? File "/usr/lib/python3.7/site-packages/MythTV/mythproto.py", line 80,
in __init__
??? self.hostname = self.db._gethostfromaddr(self.host)
? File "/usr/lib/python3.7/site-packages/MythTV/database.py", line
1348, in _gethostfromaddr
??? 'BackendServerAddr', addr)
MythTV.exceptions.MythDBError: Could not find setting
'BackendServerAddr' on host 'None'

Hostnames in use makes sense as this is a combined FE/BE.

$ echo 'select distinct hostname from mythconverg.settings;' | mysql -u
mythtv -p
Enter password:
hostname
odysseus
NULL

Gary

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 2020-05-15 1:51 p.m., Roland Ernst wrote:
> On Fri, May 15, 2020 at 3:43 PM Gary Raposo <gary@raposo.ca> wrote:
>> On 2020-05-14 5:09 p.m., Bill Meek wrote:
>>> On 5/14/20 3:19 PM, Gary Raposo wrote:
>>> ...
>>>
>>> If I have a host value that doesn't match my recordings, then I get all
>>> recordings showing up as missing.
>>>
>>> Try printing the hosts value like this:
>>>
>>> else:
>>> with DB as c:
>>> c.execute("""SELECT hostname FROM settings
>>> WHERE value='BackendServerIP'""")
>>> hosts = [r[0] for r in c.fetchall()]
>>> print('hosts=',hosts) # <---------------------------
>>>
>>> Look at some recordings. Press 'i' twice and see what the value of
>>> Recording Host: is set to.
>>>
>> Thanks for the suggestions, Bill. Still no luck.
>>
>> I checked the settings table and I do not have an entry for
>> BackendServerIP. I do have a valid/correct entry for MasterServerIP so
>> changed the code to reference MasterServerIP. No change.
>>
>> If I add the print statement you suggested, it's still showing None:
>> hosts= [None]
>>
>> Checking my recordings (pressing "i" twice) I can see that they are all
>> correctly tagged with odysseus as the hostname. MasterServerIP
>> references the correct IP address for odysseus and /etc/hosts matches.
>>
>> Looking at the query, it looks like they are pulling hostname from the
>> settings table for the entry associated with the
>> BackendServerIP/MasterServerIP. I hadn't really looked at it that
>> closely before and assumed they were pulling the hostname based on the
>> data field. Wouldn't you know it, hostname is set to NULL for that entry.
>>
>> I updated the settings table and set hostname = odysseus for
>> MasterServerIP + added an entry for BackendServerIP (just in case) and
>> now I've moved on to a whole different set of problems!
>>
>> Before, I was able to see all my recordings but they were listed as
>> "Recordings with missing files". Now I get no output and the following
>> errors:
>>
>> $ ./find_orphans.py
>> Traceback (most recent call last):
>> File "./find_orphans.py", line 222, in <module>
>> BE = MythBE(db=DB)
>> File "/usr/lib/python3.7/site-packages/MythTV/mythproto.py", line 80,
>> in __init__
>> self.hostname = self.db._gethostfromaddr(self.host)
>> File "/usr/lib/python3.7/site-packages/MythTV/database.py", line
>> 1348, in _gethostfromaddr
>> 'BackendServerAddr', addr)
>> MythTV.exceptions.MythDBError: Could not find setting
>> 'BackendServerAddr' on host 'None'
>>
>> Not too sure what's going on. Looking at the settings table, I have
>> three entries: BackendServerIP, MasterServerIP, and BackendServerAddr.
>> All have data set to 10.10.10.20 and hostname = odysseus.
>>
>> I'm poking around now in mythproto.py and database.py but (again) my
>> lack of Python experience is making this a slow process.
>>
>> As always, any suggestions are welcome.
>>
>> Gary
>
> Gary
> MythTV v29 changed the behaviour for
> 'BackendServerAddr', 'BackendServerIP', 'BackendServerIP6'
> as described in ticket https://code.mythtv.org/trac/ticket/13024.
>
> In short:
> If someone explicitly wants a 'BackendServerIP' or 'BackendServerIP6'
> this must be entered in the database during the setup step.
> But 'BackendServerAddr' should be always in the database for each backend.
>
> The script 'find_orphans.py' iterates over all backends, therefore
> I kindly ask you to change every occurrence of
> 'BackendServerIP' to 'BackendServerAddr' in this script and try again.
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://lists.mythtv.org/mailman/listinfo/mythtv-users
> http://wiki.mythtv.org/Mailing_List_etiquette
> MythTV Forums: https://forum.mythtv.org

Thanks, everyone, for your help and suggestions. It seems to be working now.

Here's what I did (taking into account feedback from the last few
replies to this thread):

- updated the settings table to revert the hostname field back to NULL
for MasterServerIP
- deleted and rebuilt find_orphans.py from
https://www.mythtv.org/wiki/Find_orphans.py (too many print statements
and changes so I wanted to make sure I didn't introduce any errors myself)
- updated find_orphans.py to use BackendServerAddr not BackendServerIP
- ran mythutil --clearcache

find_orphans.py now runs as expected. The net of it seems to be the
change to BackendServerAddr + running mythutil --clearcache for good
measure.

Thanks again!
Gary

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: find_orphans.py not working as expected [ In reply to ]
On 2020-05-13 2:30 p.m., Bill Meek wrote:
>> On 5/13/20 12:58 PM, Gary Raposo wrote:
>>> Hello all,
>>>
>>> During this extended period of physical distancing, I decided to
>>> rebuild my MythTV system. Overall it was a fairly smooth process and
>>> I'm now running MythTV 31 (installed from the RPM Fusion repo) on
>>> Fedora 31. Everything seems to be working as expected except for
>>> find_orphans.py. On my previous system I was using the old
>>> myth.find_orphans.pl so this is my first experience with
>>> find_orphans.py. My ultimate goal is to schedule find_orphans.py to
>>> run on a regular basis so that it will send an email if it
>>> encounters any issues.
>>>
>>> I've copied the code from
>>> https://www.mythtv.org/wiki/Find_orphans.py (find_orphans.py (for
>>> v31+)) and it runs but the results are a little confusing. Basically
>>> find_orphans.py returns every single recording as "Recordings with
>>> missing files".
>>>
>>> $ ./find_orphans.py
>>> Recordings with missing files
>>> ...
>>> ?? odysseus: Saturday Night Live - SNL At
>>> Home??????????????????????????????? 10201_20200510032700.ts
>>> ...
>>> Count:???????? 127
>>> Please select from the following
>>> ??1. Delete orphaned recording entries
>>> ??2. Refresh list
>>> ?>
>>>
>>> I can confirm that the relevant files are in the recordings
>>> directory (e.g., 10201_20200510032700.ts). I can see and play the
>>> recording via mythfrontend as well as mythweb. Everything seems to
>>> be in order except for the find_orphans.py output.
>>>
>>> Is anyone else having issues with find_orphans.py? I'm not
>>> proficient with Python so looking for any tips, tricks, or guidance
>>> on how to get find_orphans.py working.
>>
>> "Works for me". Begin guess mode.
>>
>> New host (and/or new hostname)? What do these return:
>>
>> ? curl --header 'Accept:application/json'
>> localhost:6544/Myth/GetHostName
>> ? hostname
>>
>> As to scheduling, the program is interactive (so you must say yes to
>> things to be deleted.)
>>

Bill, just wanted to revisit the interactive nature of find_orphans.py.
I've been looking at Python long enough to be dangerous now. I copied
find_orphans.py to find_orphans_cron.py and changed the main function to:

def main(host=None):
??? recs, zerorecs, orphvids, orphimgs, dbbackup, unfiltered =
populate(host)

??? if len(recs):
??????? printrecs("Recordings with missing files", recs)
??? if len(zerorecs):
??????? printrecs("Zero byte recordings", zerorecs)
??? if len(orphvids):
??????? printfiles("Orphaned video files", orphvids)
??? if len(orphimgs):
??????? printfiles("Orphaned snapshots", orphimgs)
??? if len(unfiltered):
??????? printfiles("Other files", unfiltered)

I stripped everything else out so that it just runs through with no
input expected/required. I then dropped find_orphans_cron.py into cron
so that it runs on a regular basis. I can review the report and launch
the interactive find_orphans.py if needed to clean up.

Not exactly elegant but it gets the job done :)

Gary
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org