|
| Author |
Message |
latenighttech
Joined: 02 Apr 2008 Posts: 2
|
Posted: Wed Apr 02, 2008 5:48 pm Post subject: Display order of shares (appears to be somewhat random?) |
|
|
I'm a VERY happy user of pyTivo, running "KRKeegan's fork" (pyTivo-v2008.03.28 ) with subfolder hack enabled. Something that's been perplexing me for some time, and I've not found any references to this issue on any of the discussion boards (however please forgive me if this is an "old" issue and I just missed it) ... how is the display order of shares on the NPL determined, and can I influence it? I would have expected they would just be displayed the way I have them ordered in my pyTivo.conf file, but it seems to have a mind of it's own. It appears to select them almost alphabetically by the drive letter and path, but that's not totally consistent either. Is there a way to force pyTivo to display my shares in the order I desire?
Thx! |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 448 Location: Los Angeles, CA
|
Posted: Wed Apr 02, 2008 8:17 pm Post subject: |
|
|
No it is pretty random. From memory I think it is controlled by a dict variable in python. The sorting of Dict variables in python is notoriously random. (I am sure it is influenced by something, but the output at least appears random).
I would be willing to add an enhancement to sort the shares, the question is how to do it.
Sorting options:
1. It would probably be fairly easy to make it alphabetical.
2. Sorting it in the same order as the conf file might be more difficult. The configuration module doesn't seem to store the settings in any particular order. Thus there is no real way to sort things from the admin plugin.
3. Add another setting to the shares which influences their sort order. i.e. sort_order = 1 This seems a little ridiculous.
I think alphabetical makes the most sense, but I am not sure it provides the result ppl are looking for. |
|
| Back to top |
|
 |
reneg
Joined: 04 Jan 2008 Posts: 116
|
Posted: Wed Apr 02, 2008 9:51 pm Post subject: |
|
|
| Alphabetically would make the most sense to me, but I don't think it will help if there is more than one instance of pyTivo running. At that point, it's up to the Tivo to display the various shares that it sees. |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 448 Location: Los Angeles, CA
|
Posted: Wed Apr 02, 2008 10:20 pm Post subject: |
|
|
| reneg wrote: | Alphabetically would make the most sense to me, but I don't think it will help if there is more than one instance of pyTivo running. At that point, it's up to the Tivo to display the various shares that it sees. | Yes that cannot be fixed AFAIK. |
|
| Back to top |
|
 |
latenighttech
Joined: 02 Apr 2008 Posts: 2
|
Posted: Thu Apr 03, 2008 1:25 am Post subject: |
|
|
Thanks for the responses. In my case, I have only one instance of pyTivo running, so I'm not concerned about the multi-pyTivo randomness. Honestly, if "option 2" (order listed in config file) won't work, my preference would still be "option 3" (even though it may seem overkill) so that I can explicitly set the order to my liking. Or perhaps default to alphabetic (so at least it wouldn't be random), then provide an override for "experts" where one could explicitly set the display order. I have quite a few shares and would like to logically group them and not have to depend on giving them alpha-sort titles to get them to display the way I like.
But, beggars can't be choosers ... I appreciate the support to do something to make it more predictable, then I can work around whatever solution turns out to be.
Thanks! |
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 448 Location: Los Angeles, CA
|
Posted: Thu Apr 03, 2008 1:39 am Post subject: |
|
|
| Ok let me ponder over the possibility of sorting based on the order in the pyTivo.conf file. Sometimes I come up with good ideas while I sleep. |
|
| Back to top |
|
 |
reneg
Joined: 04 Jan 2008 Posts: 116
|
Posted: Fri Apr 04, 2008 1:23 am Post subject: |
|
|
May not be pretty, but this works on my system:
In httpserver.py in root_container, added the 5 lines after t = Template
| Code: |
t = Template(file=os.path.join(SCRIPTDIR, 'templates',
'root_container.tmpl'))
shares = sorted(tsncontainers.keys())
content = []
for x in shares:
content.append(tsncontainers[x]['content_type'])
t.tempcontainer = zip(shares,content)
t.containers = tsncontainers
|
and in root_container.tmpl, changed the for loop as follows:
| Code: |
#for $name, $details in $tempcontainer
<Item>
<Details>
<Title>$escape($name)</Title>
<ContentType>$escape($details)</ContentType>
<SourceFormat>x-container/folder</SourceFormat>
</Details>
<Links>
<Content>
<Url>/TiVoConnect?Command=QueryContainer&Container=$escape($name)</Url>
<ContentType>$escape($details)</ContentType>
</Content>
</Links>
</Item>
#end for
|
|
|
| Back to top |
|
 |
krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 448 Location: Los Angeles, CA
|
Posted: Fri Apr 04, 2008 5:32 am Post subject: |
|
|
Wait this only sorts alphabetically??
Yeah that is pretty easy to accomplish. It is the sort by order in pytivo.conf that has me more stumped. |
|
| Back to top |
|
 |
reneg
Joined: 04 Jan 2008 Posts: 116
|
Posted: Fri Apr 04, 2008 3:34 pm Post subject: |
|
|
Yes, it is alphabetical. Option 1 is simple and it makes my NPL esthetically pleasing with the 12 shares that I have defined.
I think option 2 is more trouble than it's worth. You would have to rework getShares in config.py. Processing sections in the conf file in order would imply that ConfigParser returns sections in a certain order or you would have to figure out another way to specify ordering. |
|
| Back to top |
|
 |
dlw283
Joined: 08 Nov 2009 Posts: 4
|
Posted: Sun Nov 08, 2009 1:20 pm Post subject: Code change outdated |
|
|
| This code change is dated. Has anyone updated it to work with the newer versions of pyTivo? |
|
| Back to top |
|
 |
wmcbrine

Joined: 04 Jan 2008 Posts: 1229
|
Posted: Sun Nov 08, 2009 2:45 pm Post subject: |
|
|
OK, I've added sorting in my fork. It's a one-line change. _________________ My pyTivo fork |
|
| Back to top |
|
 |
reneg
Joined: 04 Jan 2008 Posts: 116
|
Posted: Sun Nov 08, 2009 6:15 pm Post subject: |
|
|
Thanks for incorporating the change into your git, however I tried the new git and it didn't seem to work correctly in my configuration. I rebooted my Tivo just to make sure it was starting fresh. I haven't stepped through the code to verify, but I don't think the tsncontainers are necessarily sorted after going through this bit of code in the root_container function in httpserver.py:
| Code: | tsnshares = config.getShares(tsn)
tsncontainers = {}
for section, settings in tsnshares:
try:
settings['content_type'] = \
GetPlugin(settings['type']).CONTENT_TYPE
tsncontainers[section] = settings
except Exception, msg:
self.server.logger.error(section + ' - ' + str(msg))
t = Template(file=os.path.join(SCRIPTDIR, 'templates',
'root_container.tmpl'),
|
|
|
| Back to top |
|
 |
dlw283
Joined: 08 Nov 2009 Posts: 4
|
Posted: Sun Nov 08, 2009 6:26 pm Post subject: Share Sort Works Now |
|
|
It looks much better now. Thanks for the update, I knew you would make it look easy!  |
|
| Back to top |
|
 |
reneg
Joined: 04 Jan 2008 Posts: 116
|
Posted: Sun Nov 08, 2009 7:01 pm Post subject: |
|
|
| If I comment out my 'shares=' in my pyTivo.conf, it does a better job of sorting. Commenting out my shares= had the side effect of enabling zeroconf which announced the shares which caused Zeroconf.py to barf on the share named "O.C.". A period in the share is apparently bad. After I edited my pyTivo.conf to change "O.C." to "OC", my shares sorted mostly alphabetically, however "OC" showed up at the bottom. My guess is that sort is not compatible with share= |
|
| Back to top |
|
 |
wmcbrine

Joined: 04 Jan 2008 Posts: 1229
|
Posted: Mon Nov 09, 2009 12:14 am Post subject: |
|
|
OK, fixed that too.
Yeah, periods are used as separators at the Zeroconf level; I don't know if it's possible to use them in share names. Edit: Actually it's only a trailing dot that it doesn't like. If I add a space past that, it's OK (I didn't check it on the TiVo yet, though). _________________ My pyTivo fork |
|
| Back to top |
|
 |
|