Merge lp:~rockstar/entertainer/entertainer-server into lp:entertainer

Proposed by Paul Hummer
Status: Merged
Approved by: Paul Hummer
Approved revision: 383
Merge reported by: Paul Hummer
Merged at revision: not available
Proposed branch: lp:~rockstar/entertainer/entertainer-server
Merge into: lp:entertainer
Diff against target: None lines
To merge this branch: bzr merge lp:~rockstar/entertainer/entertainer-server
Reviewer Review Type Date Requested Status
Matt Layman Approve
Jamie Bennett (community) Abstain
Samuel Buffet (community) Approve
Review via email: mp+5224@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

This branch adds the start of the new server code. There's a lot here, and
it's just a proving a working concept, but I think it's important that it gets
into trunk. I re-arranged some of the modules to make more sense, and to
avoid things like "from
entertainerlib.really.long.import.that.breaks.the.line import something"
I've created a few scripts. I know the server and temporary client are
working now because I can run the entertainer-server script in one terminal,
and then run the client script in another terminal, and get the list of dicts
passed across. This is a simple static implementation of a command that will
be used.

What I need to do now is create a new indexer that will give me data in the
new data format (using the Storm models). Once I have a full database
implementation, I can start writing good tests for the current server
implementation, and then move on to the full server implementation.

The plan after that is to make the frontend merely a network client, which
will be rather trivial compared to these other two steps.

--
Paul Hummer
http://theironlion.net
1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F

Revision history for this message
Samuel Buffet (samuel-buffet) wrote :

Hi Paul,

So this is the beginning of the new server. Great, I hope we'll do a lot of good things with it.

Here is my review :

goal of the branch : ok
make test : ok
make lint : ok

>=== modified file 'cfg/preferences.conf'
>--- cfg/preferences.conf 2009-03-08 21:29:32 +0000
>+++ cfg/preferences.conf 2009-04-05 18:22:45 +0000
>@@ -5,7 +5,7 @@
> stage_width = 1366
> stage_height = 768
> show_effects = True
>-start_in_fullscreen = True
>+start_in_fullscreen = False

Paul, I think you can let *True* here. Don't you prefer to start Entertainer in Fullscreen ?

=== modified file 'entertainerlib/frontend/__init__.py'
--- entertainerlib/frontend/__init__.py 2009-03-08 03:16:25 +0000
+++ entertainerlib/frontend/__init__.py 2009-04-05 18:22:45 +0000
@@ -1,15 +1,10 @@
 '''Frontend gui to entertainer'''
-# pylint: disable-msg=W0612

 def main(*args, **kwargs):
     '''Frontend runner'''

>- # Import statements are inside the function so that they aren't imported
>+ # Import statements are inside thu function so that they aren't imported

Hmm, I'm not sure because I'm far from being an English expert but I can't understand *thu*.

=== modified file 'entertainerlib/frontend/gui/screens/movie.py'
--- entertainerlib/frontend/gui/screens/movie.py 2009-03-21 22:43:10 +0000
+++ entertainerlib/frontend/gui/screens/movie.py 2009-04-05 18:22:45 +0000
@@ -214,8 +214,8 @@
         if self.menu.is_active():
             item = self.menu.get_current_menuitem().get_userdata()
             if item == "watch":
- self.media_player.set_media(self.movie)
- self.media_player.play()
+ self.mediaplayer.set_media(self.movie)
+ self.mediaplayer.play()
                 self.callback("video_osd")

Paul, this is really media_player and not mediaplayer otherwise we have an error. This was fixed by laymansterms recently so I'm wondering if this branch merged recently ?

review: Needs Fixing
Revision history for this message
Samuel Buffet (samuel-buffet) wrote :
Download full text (7.8 KiB)

Hi Paul,

I've merged your branch with latest trunk (no conflicts) to have a smaller diff :

=== added file 'entertainer-client'
--- entertainer-client 1970-01-01 00:00:00 +0000
+++ entertainer-client 2009-04-05 18:22:45 +0000
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+'''Test client for Entertainer's server.
+
+This code will go away when the client code is integrated into what is now the
+frontend.
+'''
+
+from entertainerlib.network import client_main
+
+client_main()

=== added file 'entertainer-server'
--- entertainer-server 1970-01-01 00:00:00 +0000
+++ entertainer-server 2009-04-05 18:22:45 +0000
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+'''Server executable'''
+
+from entertainerlib.network import server_main
+
+server_main()
+

=== modified file 'entertainerlib/backend/core/db/models.py'
--- entertainerlib/backend/core/db/models.py 2009-01-31 21:47:47 +0000
+++ entertainerlib/backend/core/db/models.py 2009-04-05 18:22:45 +0000
@@ -5,6 +5,7 @@
 from storm.properties import Bool, DateTime, Int, Unicode
 from storm.references import Reference, ReferenceSet

+
 class BaseModel(Storm):
     '''Abstract class from which all Entertainer models inherit.'''

=== added directory 'entertainerlib/network'
=== added file 'entertainerlib/network/__init__.py'
--- entertainerlib/network/__init__.py 1970-01-01 00:00:00 +0000
+++ entertainerlib/network/__init__.py 2009-04-05 18:22:45 +0000
@@ -0,0 +1,38 @@
+'''Network functionality for Entertainer.'''
+import sys
+
+from twisted.internet import reactor
+from twisted.internet.protocol import ClientCreator
+from twisted.python.log import startLogging
+
+from entertainerlib.network.local.server import EntertainerLocalServer
+from entertainerlib.network.local.client import EntertainerLocalClientProtocol
+
+# Entertainer really needs a good absctractable way to handle command line
+# arguments.
+def server_main(*args, **kwargs):
+ '''Entertainer Server main function.'''
+ # When multiple server types are supported, the following variable will be
+ # more dynamic.
+ startLogging(sys.stdout)
+ server_type = EntertainerLocalServer
+
+ server = server_type()
+ # TODO: This port number could probably be a config var.
+ reactor.listenTCP(5545, server)
+ reactor.run()
+
+
+def client_main():
+ '''Entertainer test client code.
+
+ This code will go away when what is now the frontend is made into a true
+ client.
+ '''
+ startLogging(sys.stdout)
+ client = EntertainerLocalClientProtocol
+
+ ClientCreator(reactor, client).connectTCP(
+ 'localhost', 5545)
+ reactor.run()
+

=== added directory 'entertainerlib/network/local'
=== added file 'entertainerlib/network/local/__init__.py'
--- entertainerlib/network/local/__init__.py 1970-01-01 00:00:00 +0000
+++ entertainerlib/network/local/__init__.py 2009-04-05 18:22:45 +0000
@@ -0,0 +1,1 @@
+'''Local network storage and server package.'''

=== added file 'entertainerlib/network/local/client.py'
--- entertainerlib/network/local/client.py 1970-01-01 00:00:00 +0000
+++ entertainerlib/network/local/client.py 2009-04-05 18:22:45 +0000
@@ -0,0 +1,35 @@
+'''Classes to produce a local storage implementation.'''
+# pylint: d...

Read more...

Revision history for this message
Samuel Buffet (samuel-buffet) wrote :

Hi Paul,

Forget my previous comments here are the good ones :

Here is my review :

goal of the branch : ok
make test : ok
make lint : ok

Ok, the code looks good to me. Entertainer and its backend seems to work.

Thanks to make our backend better.
Samuel-

Revision history for this message
Samuel Buffet (samuel-buffet) :
review: Approve
Revision history for this message
Jamie Bennett (jamiebennett) wrote :

I'm not sure this should land in trunk just yet. As you say its concept
code that isn't used and hence my view would be to continue to mature it
in its own branch. Although it isn't a show stopper to merge it
(explaining my review decision).

Code wise, from my little twisted knowledge, looks OK as a dummy test of
the functionality. One comment, I would definitely make the port number
a config variable as your comments allude to. Port clashing should be
avoided and as this port could be anything (its non-standard) we can't
presume it isn't already in use on our users systems.

 review abstain

On Sat, 2009-04-04 at 17:05 +0000, Paul Hummer wrote:
> Paul Hummer has proposed merging lp:~rockstar/entertainer/entertainer-server into lp:entertainer.
>
> Requested reviews:
> Entertainer Release Team (entertainer-releases)
>
> This branch adds the start of the new server code. There's a lot here, and
> it's just a proving a working concept, but I think it's important that it gets
> into trunk. I re-arranged some of the modules to make more sense, and to
> avoid things like "from
> entertainerlib.really.long.import.that.breaks.the.line import something"
> I've created a few scripts. I know the server and temporary client are
> working now because I can run the entertainer-server script in one terminal,
> and then run the client script in another terminal, and get the list of dicts
> passed across. This is a simple static implementation of a command that will
> be used.
>
> What I need to do now is create a new indexer that will give me data in the
> new data format (using the Storm models). Once I have a full database
> implementation, I can start writing good tests for the current server
> implementation, and then move on to the full server implementation.
>
> The plan after that is to make the frontend merely a network client, which
> will be rather trivial compared to these other two steps.
>
> --
> Paul Hummer
> http://theironlion.net
> 1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F
>

review: Abstain
Revision history for this message
Matt Layman (mblayman) wrote :

I know you said you'll be merging this into some other branch, so I'm approving on those grounds (because there looks to be some things that you just wouldn't merge onto a production trunk), but here are my comments.

1) Port number stuff is already in the Configuration class. That could be used, but in the long run I don't know how we could "announce" that a server is available to connect to (is that something that would happen if we eventually add uPnP support?).

2) I'm assuming that pylint W0223 will be removed as soon as LocalStorage actually implements the abstract Storage methods. I think that could benefit from a XXX comment to help remember.

3) pylint R0922 could also benefit from a XXX comment in the pylintrc file. I don't think that the intention would be to remove it permanently as it seems to add value (especially if we start using more abstract classes).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'entertainer-client'
2--- entertainer-client 1970-01-01 00:00:00 +0000
3+++ entertainer-client 2009-04-04 05:30:04 +0000
4@@ -0,0 +1,10 @@
5+#!/usr/bin/env python
6+'''Test client for Entertainer's server.
7+
8+This code will go away when the client code is integrated into what is now the
9+frontend.
10+'''
11+
12+from entertainerlib.network import client_main
13+
14+client_main()
15
16=== added file 'entertainer-server'
17--- entertainer-server 1970-01-01 00:00:00 +0000
18+++ entertainer-server 2009-04-04 04:24:46 +0000
19@@ -0,0 +1,7 @@
20+#!/usr/bin/env python
21+'''Server executable'''
22+
23+from entertainerlib.network import server_main
24+
25+server_main()
26+
27
28=== modified file 'entertainerlib/backend/core/db/models.py'
29--- entertainerlib/backend/core/db/models.py 2009-01-31 21:47:47 +0000
30+++ entertainerlib/backend/core/db/models.py 2009-04-04 04:27:46 +0000
31@@ -5,6 +5,7 @@
32 from storm.properties import Bool, DateTime, Int, Unicode
33 from storm.references import Reference, ReferenceSet
34
35+
36 class BaseModel(Storm):
37 '''Abstract class from which all Entertainer models inherit.'''
38
39
40=== added directory 'entertainerlib/network'
41=== added file 'entertainerlib/network/__init__.py'
42--- entertainerlib/network/__init__.py 1970-01-01 00:00:00 +0000
43+++ entertainerlib/network/__init__.py 2009-04-04 05:30:04 +0000
44@@ -0,0 +1,38 @@
45+'''Network functionality for Entertainer.'''
46+import sys
47+
48+from twisted.internet import reactor
49+from twisted.internet.protocol import ClientCreator
50+from twisted.python.log import startLogging
51+
52+from entertainerlib.network.local.server import EntertainerLocalServer
53+from entertainerlib.network.local.client import EntertainerLocalClientProtocol
54+
55+# Entertainer really needs a good absctractable way to handle command line
56+# arguments.
57+def server_main(*args, **kwargs):
58+ '''Entertainer Server main function.'''
59+ # When multiple server types are supported, the following variable will be
60+ # more dynamic.
61+ startLogging(sys.stdout)
62+ server_type = EntertainerLocalServer
63+
64+ server = server_type()
65+ # TODO: This port number could probably be a config var.
66+ reactor.listenTCP(5545, server)
67+ reactor.run()
68+
69+
70+def client_main():
71+ '''Entertainer test client code.
72+
73+ This code will go away when what is now the frontend is made into a true
74+ client.
75+ '''
76+ startLogging(sys.stdout)
77+ client = EntertainerLocalClientProtocol
78+
79+ ClientCreator(reactor, client).connectTCP(
80+ 'localhost', 5545)
81+ reactor.run()
82+
83
84=== added directory 'entertainerlib/network/local'
85=== added file 'entertainerlib/network/local/__init__.py'
86--- entertainerlib/network/local/__init__.py 1970-01-01 00:00:00 +0000
87+++ entertainerlib/network/local/__init__.py 2009-04-04 05:30:04 +0000
88@@ -0,0 +1,1 @@
89+'''Local network storage and server package.'''
90
91=== added file 'entertainerlib/network/local/client.py'
92--- entertainerlib/network/local/client.py 1970-01-01 00:00:00 +0000
93+++ entertainerlib/network/local/client.py 2009-04-04 05:30:04 +0000
94@@ -0,0 +1,35 @@
95+'''Classes to produce a local storage implementation.'''
96+# pylint: disable-msg=W0223
97+
98+from twisted.internet.defer import inlineCallbacks
99+from twisted.protocols import amp
100+
101+from entertainerlib.network.local.commands import TenMusicTracks
102+from entertainerlib.network.storage import Storage
103+
104+
105+class EntertainerLocalClientProtocol(amp.AMP):
106+ '''The client protocol to communicate with the local server.'''
107+
108+ def connectionMade(self):
109+ '''See `twisted.protocols.Protocal.connectionMade`.'''
110+ self.get_ten_tracks(1)
111+
112+ @inlineCallbacks
113+ def get_ten_tracks(self, index):
114+ '''Get ten tracks starting with the given index.'''
115+ result = yield self.callRemote(TenMusicTracks, index=index)
116+ print result
117+
118+
119+class LocalStorage(Storage):
120+ '''A local storage implementation.'''
121+
122+ def __init__(self):
123+ Storage.__init__(self)
124+ self.protocol = EntertainerLocalClientProtocol
125+ self.host = 'localhost'
126+ # TODO: This port number could probably be a config var.
127+ self.port = 5545
128+
129+
130
131=== added file 'entertainerlib/network/local/commands.py'
132--- entertainerlib/network/local/commands.py 1970-01-01 00:00:00 +0000
133+++ entertainerlib/network/local/commands.py 2009-04-04 05:30:04 +0000
134@@ -0,0 +1,14 @@
135+'''Local network protocol commands.'''
136+from twisted.protocols import amp
137+
138+class TenMusicTracks(amp.Command):
139+ arguments = [('index', amp.Integer())]
140+ response = [
141+ ('tracks', amp.AmpList([
142+ ('id', amp.Integer()),
143+ ('filename', amp.Unicode()),
144+ ('title', amp.Unicode()),
145+ ('artist', amp.Unicode())]
146+ ))]
147+
148+
149
150=== added file 'entertainerlib/network/local/server.py'
151--- entertainerlib/network/local/server.py 1970-01-01 00:00:00 +0000
152+++ entertainerlib/network/local/server.py 2009-04-04 05:30:04 +0000
153@@ -0,0 +1,40 @@
154+'''A LocalServer for Entertainer.'''
155+
156+from twisted.internet.protocol import ServerFactory
157+from twisted.protocols import amp
158+
159+from entertainerlib.network.local import commands
160+
161+
162+class EntertainerLocalProtocol(amp.AMP):
163+ '''A local message passing protocol for Entertainer.
164+
165+ This protocol should be implemented when the client and the server are on
166+ the same machine.
167+ '''
168+
169+ def connectionLost(self, reason):
170+ '''See `twisted.protocols.Protocol.connectionLost`.'''
171+
172+ def connectionMade(self):
173+ '''See `twisted.protocols.Protocal.connectionMade`.'''
174+
175+ @commands.TenMusicTracks.responder
176+ def get_ten_music_tracks(self, index):
177+ '''Get the next ten music tracks from an index.'''
178+ return {'tracks': [
179+ {'id': 1,
180+ 'filename': u'/foo/bar/baz',
181+ 'title': u'Running with scissors',
182+ 'artist': u'Teh band'},
183+ {'id': 1,
184+ 'filename': u'/foo/bar/bas',
185+ 'title': u'Fa la la',
186+ 'artist': u'Teh band'},
187+ ]}
188+
189+
190+class EntertainerLocalServer(ServerFactory):
191+ '''A local server implementation for Entertainer.'''
192+ protocol = EntertainerLocalProtocol
193+
194
195=== renamed file 'entertainerlib/storage/base.py' => 'entertainerlib/network/storage.py'
196--- entertainerlib/storage/base.py 2009-02-06 06:34:20 +0000
197+++ entertainerlib/network/storage.py 2009-04-04 05:30:04 +0000
198@@ -1,4 +1,4 @@
199-'''Base classes for Entertainer Storages.'''
200+'''Base class for a Storage implementation.'''
201
202
203 class Storage(object):
204
205=== removed directory 'entertainerlib/storage'
206=== removed file 'entertainerlib/storage/__init__.py'
207--- entertainerlib/storage/__init__.py 2009-02-06 06:52:14 +0000
208+++ entertainerlib/storage/__init__.py 1970-01-01 00:00:00 +0000
209@@ -1,4 +0,0 @@
210-'''Storage facilities for Entertainer (used by the client/frontend).'''
211-# pylint: disable-msg=W0611
212-from entertainerlib.storage.base import Storage
213-
214
215=== modified file 'entertainerlib/tests/test_storage.py'
216--- entertainerlib/tests/test_storage.py 2009-02-10 04:54:36 +0000
217+++ entertainerlib/tests/test_storage.py 2009-04-04 05:30:04 +0000
218@@ -1,6 +1,6 @@
219 '''Test the Storage classes.'''
220 # pylint: disable-msg=W0704,W0612
221-from entertainerlib.storage import Storage
222+from entertainerlib.network.storage import Storage
223 from entertainerlib.tests import EntertainerTest
224
225 class TestStorage(EntertainerTest):
226
227=== modified file 'pylintrc'
228--- pylintrc 2009-02-10 02:34:38 +0000
229+++ pylintrc 2009-04-04 05:30:04 +0000
230@@ -61,7 +61,7 @@
231 # W0201 checks for attributes defined outside init
232
233 # XXX: rockstar - C0103 constrains method and function names to a regex
234-disable-msg=I0011,R0201,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0923,W0613,C0103,W0232,W0201,E1101,E1103,W0142
235+disable-msg=R0922,I0011,R0201,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0923,W0613,C0103,W0232,W0201,E1101,E1103,W0142
236
237
238 [REPORTS]

Subscribers

People subscribed via source and target branches