ServiceScan.py Questions...

Moderators: Gully, peteru

Post Reply
IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

ServiceScan.py Questions...

Post by IanSav » Thu Nov 03, 2016 00:47

Hi,

I have some questions and observations regarding "Components/ServiceScan.py"...
  1. What is the point, on lines 37 and 38, of locking the percentage complete to a maximum of 99%?
  2. Is the "+" at the beginning of line 72 is valid? I have not seen this before and it looks wrong to me.
  3. On line 68 the code "if tp_text == "DVB-S2":" causes the variable "tp_text" to be set but then on line 73 the value of "tp_text" is unconditionally changed making the previous definition irrelevant. Does the "+" from the previous point have any affect here? Is this another code problem?
  4. The "getChannelNumber()" call on line 96 is not working. The function, defined in "Tools/Transponder.py", appears to be broken
  5. Wouldn't it be more efficient if most of this code was replaced by calls to "Tools/Transponder.py" to do most of the service identification / string conversion work. This looks like more copied code that increases support effort and the chances to introduce errors.
  6. This code would definitely benefit from a proper PEP clean up.
I was looking at this file to improve so of the text and then found the other issues. I thought it appropriate to ensure the file was valid and clean before proposing the text changes.

Regards,
Ian.
Last edited by IanSav on Thu Nov 03, 2016 01:23, edited 1 time in total.

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: ServiceScan.py Questions...

Post by IanSav » Thu Nov 03, 2016 01:02

Hi,

By the way the "createChannelNumber()" code on lines 399 and 400 of "Components/Converter/PliExtraInfo.py" is also broken. This was previously reported but no-one confirmed my observation. Without confirmation I couldn't add a bug report in the tracker. With the new report above anyone performing a service scan should note that the channel number is now missing from the frequency display and should be able to confirm my original bug report.

I believe that some other aspects of the recent merges have broken a few things.

Regards,
Ian.

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: ServiceScan.py Questions...

Post by IanSav » Thu Nov 03, 2016 01:23

Hi,

The first post has been extended.

Regards,
Ian.

prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: ServiceScan.py Questions...

Post by prl » Thu Nov 03, 2016 09:22

IanSav wrote:...
I have some questions and observations regarding "Components/ServiceScan.py"...

What is the point, on lines 37 and 38, of locking the percentage complete to a maximum of 99%?
My guess is that it's to prevent it showing "100% completed" when it's still running. The text changes to "Scanning completed." when the scan has finished.

However, given the way that the percentage is calculated, it should never be more than 99 anyway.
IanSav wrote:s the "+" at the beginning of line 72 is valid? I have not seen this before and it looks wrong to me.
It depends on what you mean by "valid". It's part of a valid expression, provided tp.Modulation_16APSK is a type that is an acceptable target of a unary "+", which, since it's a C++ enum (with an integer base type), is true. Since it's unary '+', it will have no effect on the value, so the code will work as intended. My guess is that it's there as a result of a careless copy/paste from a unified (-u style) diff (e.g. from a git diff). In any case, it does look strange, it is redundant and it should probably go.
IanSav wrote:On line 68 the code "if tp_text == "DVB-S2":" causes the variable "tp_text" to be set but then on line 73 the value of "tp_text" is unconditionally changed making the previous definition irrelevant. Does the "+" from the previous point have any affect here? Is this another code problem?
No, it's not really making the test irrelevant. It's expanding the transponder information from just the name of the standard to the name of the standard followed by the modulation scheme. So "DVB-S2" might become, say, "DVB-S2 16APSK" or "DVB-S2 QAM16" if the test is true. I don't see anything broken here.

This code should never be reached in Beyonwiz T series devices.
IanSav wrote:The "getChannelNumber()" call on line 96 is not working. The function, defined in "Tools/Transponder.py", appears to be broken
There doesn't seem to be anything broken in Tools.Transponder.getChannelNumber(). Its implementation has changed, though, and the implementation requires the strings "DVB-T" and "Australia" to be in the "name" attribute of the <terrestrial/> element of terrestrial.xml for it to return channel numbers for Australian frequencies. These strings aren't currently in the "name" attribute. The "name" attribute would need to change from a string like "Sydney" to something like "Sydney Australia: DVB-T".

This is a problem with the current alpha. I'll post about the problem there and possibly make a new version of terrestrial.xml available for use with the alpha.
IanSav wrote:Wouldn't it be more efficient if most of this code was replaced by calls to "Tools/Transponder.py" to do most of the service identification / string conversion work. This looks like more copied code that increases support effort and the chances to introduce errors.
That's probably a good thing, provided the APIs are preserved, but there's a lot of this sort of stuff about. I hate to think about the number of different implementations of orbPos() (or orbpos()) there are lying around in the code.

NB: there's also an implementation of getChannelNumber() in Components.Converter.ChannelNumbers that should probably call Tools.Transponder.getChannelNumber(). It was that implementation that was previously used to get the channel number in Components.ServiceScan. "You are in a maze of twisty little passages, all alike."
IanSav wrote:This code would definitely benefit from a proper PEP clean up. ..
I can't disagree with that!
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: ServiceScan.py Questions...

Post by IanSav » Thu Nov 03, 2016 11:46

Hi Prl,
prl wrote:My guess is that it's to prevent it showing "100% completed" when it's still running. The text changes to "Scanning completed." when the scan has finished.

However, given the way that the percentage is calculated, it should never be more than 99 anyway.
I would rate this as code bloat and argue that it should be removed.
prl wrote:It depends on what you mean by "valid". It's part of a valid expression, provided tp.Modulation_16APSK is a type that is an acceptable target of a unary "+", which, since it's a C++ enum (with an integer base type), is true. Since it's unary '+', it will have no effect on the value, so the code will work as intended. My guess is that it's there as a result of a careless copy/paste from a unified (-u style) diff (e.g. from a git diff). In any case, it does look strange, it is redundant and it should probably go.
Agreed.
prl wrote:No, it's not really making the test irrelevant. It's expanding the transponder information from just the name of the standard to the name of the standard followed by the modulation scheme. So "DVB-S2" might become, say, "DVB-S2 16APSK" or "DVB-S2 QAM16" if the test is true. I don't see anything broken here.
I didn't see that "tp_text" is in both the left and right side of the "=" on line 73. False alarm. Move along, nothing to see here. ;)
prl wrote:There doesn't seem to be anything broken in Tools.Transponder.getChannelNumber(). Its implementation has changed, though, and the implementation requires the strings "DVB-T" and "Australia" to be in the "name" attribute of the <terrestrial/> element of terrestrial.xml for it to return channel numbers for Australian frequencies. These strings aren't currently in the "name" attribute. The "name" attribute would need to change from a string like "Sydney" to something like "Sydney Australia: DVB-T".

This is a problem with the current alpha. I'll post about the problem there and possibly make a new version of terrestrial.xml available for use with the alpha.
This data could be derived from elsewhere. I posted details in the Alpha thread.
prl wrote:That's probably a good thing, provided the APIs are preserved, but there's a lot of this sort of stuff about. I hate to think about the number of different implementations of orbPos() (or orbpos()) there are lying around in the code.

NB: there's also an implementation of getChannelNumber() in Components.Converter.ChannelNumbers that should probably call Tools.Transponder.getChannelNumber(). It was that implementation that was previously used to get the channel number in Components.ServiceScan. "You are in a maze of twisty little passages, all alike."
I am prepared to try and fix this though I doubt that PeterU would ever accept my changes.
prl wrote:
IanSav wrote:This code would definitely benefit from a proper PEP clean up. ..
I can't disagree with that!
Could you please submit a PEP clean up of the file into the repository. (I usually manually clean up the files but I don't want to try that with this much disarray.)

Regards,
Ian.

prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: ServiceScan.py Questions...

Post by prl » Thu Nov 03, 2016 12:35

Can't you install a pep8 checker? I think this is the one I use: https://pypi.python.org/pypi/pep8.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: ServiceScan.py Questions...

Post by IanSav » Thu Nov 03, 2016 13:10

Hi Prl,
prl wrote:Can't you install a pep8 checker? I think this is the one I use: https://pypi.python.org/pypi/pep8.
I will look at installing it on my development T3 now.

Do you still use the "--ignore=W191,E302,E501" setting?

Regards,
Ian.

prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: ServiceScan.py Questions...

Post by prl » Thu Nov 03, 2016 14:12

IanSav wrote:Hi Prl,
prl wrote:Can't you install a pep8 checker? I think this is the one I use: https://pypi.python.org/pypi/pep8.
I will look at installing it on my development T3 now.

Do you still use the "--ignore=W191,E302,E501" setting?

Regards,
Ian.
Yep.

Code: Select all

Cambyses:python prl$ cat ~/.config/pep8 
[pep8]
ignore=W191,E302,E501
Cambyses:python prl$ 
Peteru uses slightly more permissive settings:

Code: Select all

ignore=W191,E126,E302,E501,E265
The differences are:
E126 (*^) continuation line over-indented for hanging indent
E265 block comment should start with ‘# ‘
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: ServiceScan.py Questions...

Post by IanSav » Thu Nov 03, 2016 23:34

Hi Prl,

Can PEP8 automatically make the edits to the file being checked?

Regards,
Ian.

User avatar
peteru
Uber Wizard
Posts: 9741
Joined: Tue Jun 12, 2007 23:06
Location: Sydney, Australia
Contact:

Re: ServiceScan.py Questions...

Post by peteru » Fri Nov 04, 2016 02:50

Thanks for bringing this topic up. I've been meaning to clean this up and fix the channel scan regression for a couple of weeks now. Your inquiries prompted me to just get it done. I figured it was easier and faster to just make it work. I'm a bit pressed for time these days.

I'll try to push an update overnight.

"Beauty lies in the hands of the beer holder."
Blog.

prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: ServiceScan.py Questions...

Post by prl » Fri Nov 04, 2016 09:42

IanSav wrote: Can PEP8 automatically make the edits to the file being checked?
Not as far as I know.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: ServiceScan.py Questions...

Post by IanSav » Fri Nov 04, 2016 10:29

Hi Prl,
prl wrote:
IanSav wrote: Can PEP8 automatically make the edits to the file being checked?
Not as far as I know.
Thank you for the information and assistance. I will update my sources to PeterU's latest changes and then try submitting a simple PEP8 clean up.

Regards,
Ian.

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: ServiceScan.py Questions...

Post by IanSav » Sat Nov 05, 2016 13:07

Hi Prl,

Some of my recent pull requests particularly Pull Request #279 have featured extensive PEP8 clean ups. I used your stricter version of the defaults. How did I do? How do they look?

Regards,
Ian.

Huevos
Apprentice
Posts: 32
Joined: Fri Dec 02, 2016 05:56

Re: ServiceScan.py Questions...

Post by Huevos » Fri Dec 02, 2016 06:26

prl wrote:My guess is that it's to prevent it showing "100% completed" when it's still running.
Yes it is. It used to get to 100% while the scan was still running. So previously if it was scanning 3 transponders it would have shown 0%, 50% and 100%.

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: ServiceScan.py Questions...

Post by IanSav » Fri Dec 02, 2016 07:41

Hi Huevos,

Welcome to Australia! ;) Thank you for joining our forum.

Huevos is a member of the OpenViX team.

Regards,
Ian.

Post Reply

Return to “Developers Community”