thanks for the feed back Jasper! More feedback welcome.<div>Yes the code def. needs to be cleaned up before public release, and I will make more use of python libs for path concatenation.</div><div><br></div><div>The feedback I&#39;m specifically looking for is anything related to how I&#39;m using twisted and process management.</div>
<div>The reason I have everything in there from timing out, to killing a process, is because I&#39;m dealing with malicious websites, so bad things happen and so I need to take extreme measures to for resource monitoring.</div>
<div><br></div><div>Any suggestions on how I can do things better with the service in terms of how i&#39;m using Twisted is welcome! Jasper provided great comments and I&#39;ll be working to make those changes.</div><div>
<br></div><div>Thanks,</div><div>Stephan<br><br><div class="gmail_quote">On Thu, May 3, 2012 at 11:12 AM, Jasper St. Pierre <span dir="ltr">&lt;<a href="mailto:jstpierre@mecheye.net" target="_blank">jstpierre@mecheye.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You seem to have some indentation issues. You have a random assortment<br>
of Python style issues (some lines end with a semicolon). You use<br>
&#39;foo&#39; + &#39;/&#39; + &#39;bar&#39; to generate paths. While not evil (I think all<br>
major platforms will support that and do the translation on their<br>
own), you&#39;re better off using os.path.join. The &quot;~/.mozilla/firefox&quot;<br>
won&#39;t work on certain platforms (and you could just use<br>
os.path.expanduser if you don&#39;t want to support those platforms).<br>
<br>
Your process spawning code is ugly, and could be open to injection if<br>
not handled properly. Do it the better way:<br>
<br>
    reactor.spawnProcess(self.processProtocol, &#39;xfvb-run&#39;,<br>
[&#39;xvfv-run&#39;, &#39;--auto-servernum&#39;, &#39;firefox&#39;, &#39;-p&#39;, profile_id], env =<br>
os.environ, usePTY=1)<br>
<br>
Don&#39;t do &#39;foo == True&#39;. Please use new-style classes (inherit from<br>
&#39;object&#39;). I don&#39;t know why the timeout stuff makes me a bit scared,<br>
but it does. I don&#39;t really think timeouts are necessary here.<br>
<br>
I don&#39;t think you should be killing a process with os.kill. I&#39;m quite<br>
sure whatever you&#39;re trying to do has a better Twisted idiom.<br>
<br>
Google for PEP 8, ignore the ones that don&#39;t make sense (like foo_case<br>
instead of camelCase in Twisted code), and try to follow the rest.<br>
When using Twisted code, always look for things in Twisted that might<br>
combat the standard library, and try to use Twisted&#39;s whenever<br>
possible.<br>
<div><div class="h5"><br>
On Thu, May 3, 2012 at 11:56 AM, Stephan &lt;<a href="mailto:schenette@gmail.com">schenette@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi I have an open source project that is pretty well-known in the security<br>
&gt; community. <a href="http://www.fireshark.org" target="_blank">http://www.fireshark.org</a><br>
&gt; it&#39;s a service wrapper that runs a headless version of firefox to visit<br>
&gt; malicious sites to store telemetry data.<br>
&gt;<br>
&gt; The old service used PERL for threading (very painful), so a while ago I<br>
&gt; changed everything to python using<br>
&gt; the twisted framework. the service&#39;s job is to launch a choose a firefox<br>
&gt; profile, launch the process and<br>
&gt; handle closes and crashes approprietly.<br>
&gt;<br>
&gt; the launch of version 2.5 is next week but I sure could use some feedback on<br>
&gt; the service code before releasing it.<br>
&gt; Keep in mind I haven&#39;t finishing commenting for public release.<br>
&gt;<br>
&gt; here are the files for the new service:<br>
&gt;<br>
&gt; 1)<br>
&gt; fireshark.py <a href="http://pastebin.mozilla.org/1614427" target="_blank">http://pastebin.mozilla.org/1614427</a><br>
&gt;<br>
&gt; this is the main service. opens up a port to listen on, and uses the<br>
&gt; following two classes to manage profiles and launch<br>
&gt; a firefox process.<br>
&gt;<br>
&gt; 2)<br>
&gt; firesharkprofilemanager.py <a href="http://pastebin.mozilla.org/1614428" target="_blank">http://pastebin.mozilla.org/1614428</a><br>
&gt;<br>
&gt; this is the firefox profile manager, it manages what firefox profiles are<br>
&gt; available.<br>
&gt;<br>
&gt; 3)<br>
&gt; firefoxprocess.py <a href="http://pastebin.mozilla.org/1614431" target="_blank">http://pastebin.mozilla.org/1614431</a><br>
&gt;<br>
&gt; this is the firefox process class, to check if  the launched process has<br>
&gt; been killed as well, as check if the logging from<br>
&gt; the internal plugin (another part of the fireshark project) has completed<br>
&gt; logging.<br>
&gt;<br>
&gt; Thanks in advance! Twisted has been a great Framework!<br>
&gt; Stephan<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Twisted-Python mailing list<br>
&gt; <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
  Jasper<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</font></span></blockquote></div><br></div>