Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

Dominoes posted:

I'm learning Python, and chose Python 3 because it's the newer, refined version. You're more likely to run into compatibility problems with external modules in Python 3, since most of the information and development resources available are for Python 2. Philosophically, I suggest using Python 3 - you'd be helping push the community to upgrade.

Not to rain on your parade, but you really won't be. The scientific community may never change to Python 3 for example. The reason is the same reason why there are still many coding libraries out there in regular use that are in FORTRAN etc.

If you have a whole code base of tools written in Py2, you really don't want to spend the time "upgrading" to Py3. ESPECIALLY when half the libraries you use have completely changed how some of their functions work from 2 to 3. It's a headache I don't want to deal with, and I'm not alone there.

Python 2.6/2.7 really would be my suggestion to any newbie. **HOWEVER**, the question is, as always, "what do you want to do?" If you're just doing python for your own fun, by all means, use Py3. If you want it as a resume line, you want to find out what version of python the community you want to work with uses. Scientists who use python almost universally use Py2.x. Outside of science, I know guys who use both Py3 and Py2. While the differences aren't awful, the minor selling point that you use the version they do may help you.

Adbot
ADBOT LOVES YOU

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

BeefofAges posted:

If you're going to use subprocess with shell=True, make sure to read up on all the potential security problems that go along with it.

Also, I found that sometimes setting shell=True made the subproc run like I expected, but a little extra syntax work made it so I didn't have to use shell=True. Try to avoid it, even if you're hardcoding in all the commands. That said, there ARE times you HAVE to use it, unfortunately.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
There are never times that you have to use shell=True. If you need to unfortunately need to parse input from a configuration file (which you should never, ever, ever do), you might be able to get by with the shlex module.

Dren
Jan 5, 2001

Pillbug
shell=True neatly solves that guy's problem. If all he's doing is lspci piped through grep with no user input in the shell command then shell=True is not that bad unless I'm missing something. Suggesting that it never be used seems extreme.

Dominoes
Sep 20, 2007

Is there a way to procedurally change a function based on variables, like in a loop? The best way I can describe it is with psuedocode:

Python code:
for n in range(:10):
            self.ui.checkBox_%s.stateChanged.connect(self.check_%s) % (n, n)
In this example, I'd like to create signals for 10 QT checkboxes, without writing each one out.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Dominoes posted:

Is there a way to procedurally change a function based on variables, like in a loop? The best way I can describe it is with psuedocode:

Python code:
for n in range(:10):
            self.ui.checkBox_%s.stateChanged.connect(self.check_%s) % (n, n)
In this example, I'd like to create signals for 10 QT checkboxes, without writing each one out.

There's probably a better way to do this, and I'm tired or I would think about it and suggest one. But yes you can do that using __getattribute__.

Python code:
for n in range(:10):
    ( self.ui
          .__getattribute__('checkBox_%s' % n)
          .stateChanged
          .connect(self.__getattribute__('check_%s' % n))
          )
Totally untested, so there is probably a mistake in there that stops it working.

Dominoes
Sep 20, 2007

Hammerite posted:

There's probably a better way to do this, and I'm tired or I would think about it and suggest one. But yes you can do that using __getattribute__.

Python code:
for n in range(:10):
    ( self.ui
          .__getattribute__('checkBox_%s' % n)
          .stateChanged
          .connect(self.__getattribute__('check_%s' % n))
          )
Totally untested, so there is probably a mistake in there that stops it working.
No - your code works perfectly. Thank you! I haven't seen that syntax before, but it's evidently what I'm looking for.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
If you want to keep attributes, use getattr instead of __getattribute__, but chances are you want to use a list.

Nippashish
Nov 2, 2005

Let me see you dance!

Dren posted:

Suggesting that it never be used seems extreme.

Never use shell=True is sort of like never use lambda.

Hitch
Jul 1, 2012

I have been following this thread for a while and have loved the back-and-forth. There are quite a few folks that really know the ins and outs of the language. I'd like to get to that point. I have read several books on Python, primarily on syntax and other very small programs. I'm looking to find something a little bigger that I can really learn the language as well as Pythonic programming techniques.

I suppose my question is what did you all use to learn the language? I have an idea for what I would like to build, some form of a custom web application. Anytime I go to check out starting something with Django, I get lost in all of the complexity of the whole thing. It seems built to handle everything, when I really want to start with the bare bones and expand from there. I'd like to play around with basic site functionality, handling requests, displaying data from a database, etc. before digging into some of the details. Is there anything simple and open source that would give that flexibility?

Rohaq
Aug 11, 2006

Hitch posted:

I have been following this thread for a while and have loved the back-and-forth. There are quite a few folks that really know the ins and outs of the language. I'd like to get to that point. I have read several books on Python, primarily on syntax and other very small programs. I'm looking to find something a little bigger that I can really learn the language as well as Pythonic programming techniques.

I suppose my question is what did you all use to learn the language? I have an idea for what I would like to build, some form of a custom web application. Anytime I go to check out starting something with Django, I get lost in all of the complexity of the whole thing. It seems built to handle everything, when I really want to start with the bare bones and expand from there. I'd like to play around with basic site functionality, handling requests, displaying data from a database, etc. before digging into some of the details. Is there anything simple and open source that would give that flexibility?
It sounds like you're not having a problem with Django, so much as you're having a problem with the way in which Web Application Frameworks like Django work.

Most web frameworks use the same MVC (Model-View-Controller) setup that Django uses. If you want to build web applications, I highly advise you to start learning how to use frameworks - and Django is a pretty good one to start with.

There's a fairly decent beginner's tutorial on their site, I suggest giving it a go.

Rohaq fucked around with this message at 17:19 on Apr 10, 2013

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

Suspicious Dish posted:

There are never times that you have to use shell=True. If you need to unfortunately need to parse input from a configuration file (which you should never, ever, ever do), you might be able to get by with the shlex module.

Shlex certainly is a godsend for many instances, but I have yet to find a way to call IDL -c without shell=True and have it work right.

Suggesting that it can ALWAYS be gotten around seems implausible to me.

Smarmy Coworker
May 10, 2008

by XyloJW
Python code:
def do_thing(arg):
	if arg.__class__.__name__ is 'foo':
		'do x'
	else:
		'you are a horrible failure'
Let's say I'm throwing classes around to different modules. I've got the above going on, but is there a better way of doing this?

Also let's assume I want to extend the functionality of the method to handle different classes. Should I even do that or should I just make separate methods for each one?

accipter
Sep 12, 2003

ARACHNOTRON posted:

Python code:
def do_thing(arg):
	if arg.__class__.__name__ is 'foo':
		'do x'
	else:
		'you are a horrible failure'
Let's say I'm throwing classes around to different modules. I've got the above going on, but is there a better way of doing this?

Also let's assume I want to extend the functionality of the method to handle different classes. Should I even do that or should I just make separate methods for each one?

Why not do it the other way around by asking the class do something (and that something is class specific)?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

JetsGuy posted:

Shlex certainly is a godsend for many instances, but I have yet to find a way to call IDL -c without shell=True and have it work right.

IDL -c?

Smarmy Coworker
May 10, 2008

by XyloJW

accipter posted:

Why not do it the other way around by asking the class do something (and that something is class specific)?

I kind of answered my own question while I was pondering this, because I have the data I want to pull out in a class variable with the same name for every class I'm using. So I don't need to do what I'm trying to do and can just check if the var is there.


But to expand on the question, for future use (maybe): Assume I'm in a situation where, for some reason, I do not want the first module to be directly interacting with certain things, but I do want the classes to. And I'm dead-set on keeping those classes inside the first module.
(current use is database stuff and I want to make a little proxy to initialize my db)

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

I'm sorry, I meant to say IDL -e, which is useful for calling IDL functions from outside IDL. It opens IDL, runs the program, and closes IDL.

Example:
Python code:
idl_cmd_str = "/Applications/itt/idl/idl81/bin/idl -e " + \
            "JetsGuy_routine -quiet -args " + data_str + " " + arg_1 + " " + \
            arg_2 + " " + arg_3 + " " + arg_4 + " " + \
            arg_5

#print idl_cmd_str
do_barying = subp.Popen(idl_cmd_str, shell=True).wait()
(yes, I realize upon posting this tha I should have used Shlex for the string)

Scaevolus
Apr 16, 2007

ARACHNOTRON posted:

Python code:
def do_thing(arg):
	if arg.__class__.__name__ is 'foo':
		'do x'
	else:
		'you are a horrible failure'
Let's say I'm throwing classes around to different modules. I've got the above going on, but is there a better way of doing this?

Also let's assume I want to extend the functionality of the method to handle different classes. Should I even do that or should I just make separate methods for each one?

Avoid it if you can, but if you must, use isinstance
Python code:
def do_thing(arg):
	if isinstance(arg, foo):
		'do x'
	else:
		'you are a horrible failure'
code:
isinstance(...)
    isinstance(object, class-or-type-or-tuple) -> bool
    
    Return whether an object is an instance of a class or of a subclass thereof.
    With a type as second argument, return whether that is the object's type.
    The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for
    isinstance(x, A) or isinstance(x, B) or ... (etc.).

Smarmy Coworker
May 10, 2008

by XyloJW
I know about isinstance but how is that going to work if my classes are in a different module and this one doesn't import anything?

Because I thought about using it, decided to look up whether or not it would work, and got a big "there is seriously no info on that, sucker".

Smarmy Coworker fucked around with this message at 23:53 on Apr 10, 2013

Scaevolus
Apr 16, 2007

You want this function to specially handle a specific class, but you don't want to import the definition of that class?

This sounds really weird. What are you actually trying to accomplish?

Smarmy Coworker
May 10, 2008

by XyloJW
Actually that possibility didn't even cross my mind. I don't know what I was thinking!!

Dominoes
Sep 20, 2007

Is there a working PDF manipulation module for Python 3? I've tried Pypdf, but it glitches out when I try to install with PIP. I'd like to merge PDF files. If I use Pypdf2, I get the following message using this code:

code:
with open('test1.pdf', 'rb') as f:
    with open('test2.pdf', 'rb') as f2:
        merger = PdfFileMerger()
        merger.merge(position=0, fileobj=f2)
        merger.merge(position=0, fileobj=f)
        merger.write(open("test_out.pdf", 'wb'))


"File "c:\...merger.py", line 97, in merge
elif type(fileobj) == file:
NameError: global name 'file' is not defined"

Line 97 of merger.py is " elif type(fileobj) == file:"

I get similar errors in my own code when using code such as

"input1 = PdfFileReader(file("document1.pdf", "rb"))" - that's a copy and paste from http://www.blog.pythonlibrary.org/2012/07/11/pypdf2-the-new-fork-of-pypdf/

Dominoes fucked around with this message at 02:22 on Apr 11, 2013

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

JetsGuy posted:

I'm sorry, I meant to say IDL -e, which is useful for calling IDL functions from outside IDL. It opens IDL, runs the program, and closes IDL.

Example:
Python code:
idl_cmd_str = "/Applications/itt/idl/idl81/bin/idl -e " + \
            "JetsGuy_routine -quiet -args " + data_str + " " + arg_1 + " " + \
            arg_2 + " " + arg_3 + " " + arg_4 + " " + \
            arg_5

#print idl_cmd_str
do_barying = subp.Popen(idl_cmd_str, shell=True).wait()
(yes, I realize upon posting this tha I should have used Shlex for the string)

Python code:
args = ["/Applications/itt/idl/idl81/bin/idl", "-e", "JetsGuy_routine", "-quiet", "-args",
        data_str, arg_1, arg_2, arg_3, arg_4, arg_5]

do_barying = subp.Popen(args).wait()

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Hitch posted:

I have been following this thread for a while and have loved the back-and-forth. There are quite a few folks that really know the ins and outs of the language. I'd like to get to that point. I have read several books on Python, primarily on syntax and other very small programs. I'm looking to find something a little bigger that I can really learn the language as well as Pythonic programming techniques.

I suppose my question is what did you all use to learn the language? I have an idea for what I would like to build, some form of a custom web application. Anytime I go to check out starting something with Django, I get lost in all of the complexity of the whole thing. It seems built to handle everything, when I really want to start with the bare bones and expand from there. I'd like to play around with basic site functionality, handling requests, displaying data from a database, etc. before digging into some of the details. Is there anything simple and open source that would give that flexibility?

Just do your project and stop worrying about it all! I never read any books about Python; what really got me to learn it well was when I forced myself to actually start using it a lot. Every time I had an idea for a project, I'd do it in Python and see it through. Google, the official documentation, this thread, stack overflow, stuff like that. I don't post much in here but after a few years of just using the language I understand a lot of ins and outs, little tricks, common patterns and stuff like that. It will come naturally as long as you're reading a lot of other people's code and writing a lot of your own!

Smarmy Coworker
May 10, 2008

by XyloJW
For the python-daemon library (if anyone is familiar), how do I set it so a process doesn't have a timeout and will run forever? Just self.timeout = 0? The reason I ask is I'm having a rabbitmq worker (using pika) consume messages from a channel, and it sleeps until there is a message so it just dies when the timeout is up and no messages have been received, which I don't want.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

MeramJert posted:

Just do your project and stop worrying about it all! I never read any books about Python; what really got me to learn it well was when I forced myself to actually start using it a lot. Every time I had an idea for a project, I'd do it in Python and see it through. Google, the official documentation, this thread, stack overflow, stuff like that. I don't post much in here but after a few years of just using the language I understand a lot of ins and outs, little tricks, common patterns and stuff like that. It will come naturally as long as you're reading a lot of other people's code and writing a lot of your own!

Yeah, I think this is right.

I also have the tendency to want to try to understand the whole Whatsit before I start doing something with the Whatsit.

That doesn't work too well though.

Just start using the Whatsit and fix problems and learn things as you need them. And be prepared to go back and rewrite large swaths as you learn more. Also don't get complacent. When you get something working using Whatsit Feature X, don't just forget about it. When you're reading stuff about Whatsit and see something new about Feature X that makes how you used it stupid...go back and fix it.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

Suspicious Dish posted:

Python code:
args = ["/Applications/itt/idl/idl81/bin/idl", "-e", "JetsGuy_routine", "-quiet", "-args",
        data_str, arg_1, arg_2, arg_3, arg_4, arg_5]

do_barying = subp.Popen(args).wait()

I'll try this when I get to the machine that has the procedure, but I seem to remember the computer complaining loudly about not knowing what to do without the shell.

Thanks though!

DARPA
Apr 24, 2005
We know what happens to people who stay in the middle of the road. They get run over.

ARACHNOTRON posted:

For the python-daemon library (if anyone is familiar), how do I set it so a process doesn't have a timeout and will run forever? Just self.timeout = 0? The reason I ask is I'm having a rabbitmq worker (using pika) consume messages from a channel, and it sleeps until there is a message so it just dies when the timeout is up and no messages have been received, which I don't want.
It sounds like your application isn't looping. You might need something like:
Python code:
def main():
    while RUNNING:
        do_your_program_stuff()
        sleep(for_some_time)
edit: It looks like pika's connection.start_consuming() should block indefinitely, so you don't need to write your own while loop. Are you creating the pika connection prior to entering the DaemonContext? python-daemon will close all open file handles (including sockets) which will mess up a preexisting pika connection.

DARPA fucked around with this message at 19:58 on Apr 11, 2013

Rohaq
Aug 11, 2006

ARACHNOTRON posted:

For the python-daemon library (if anyone is familiar), how do I set it so a process doesn't have a timeout and will run forever? Just self.timeout = 0? The reason I ask is I'm having a rabbitmq worker (using pika) consume messages from a channel, and it sleeps until there is a message so it just dies when the timeout is up and no messages have been received, which I don't want.

I'm also interested in writing a RabbitMQ listener daemon in Python, as it happens, to replace a perl script I wrote a year back that's started misbehaving recently for reasons unknown. Any tips?

FoiledAgain
May 6, 2007

I thought I understood unicode encoding/decoding, but this has me really confused. I have a big set of objects called Segments that respresent consonants and vowels of a language. It's partially random which Segments end up in any given run of my program, so I like to check in the interactive window. I'm having trouble getting the right symbols to print.

The relevent part of the Segment object is this part:

code:
class Segment(object):

    def __init__(self,symbol,*args):
        self.symbol = symbol
        #other stuff

    def __str__(self):
        return self.symbol

    def __repr__(self):
        return self.__str__()

Most of the symbols are characters from the International Phonetic Alphabet, and they aren't representable using the ascii codec. This is what happens in an interactive window:

code:

>>> m = Segment('m̥')#Normally these symbols come from a textfile, I don't assign them like this

>>>print m.symbol
m̥

>>> print m
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0325' in position 1: ordinal not in range(128)

>>>m.symbol
u'm\u0325'

>>>m
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "<string>", line 548, in pphook
  File "C:\Python27\lib\pprint.py", line 56, in pprint
    printer.pprint(object)
  File "C:\Python27\lib\pprint.py", line 114, in pprint
    self._format(object, self._stream, 0, 0, {}, 0)
  File "C:\Python27\lib\pprint.py", line 137, in _format
    rep = self._repr(object, context, level - 1)
  File "C:\Python27\lib\pprint.py", line 230, in _repr
    self._depth, level)
  File "C:\Python27\lib\pprint.py", line 242, in format
    return _safe_repr(object, context, maxlevels, level)
  File "C:\Python27\lib\pprint.py", line 327, in _safe_repr
    rep = repr(object)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0325' in position 1: ordinal not in range(128)
I thought that typing m in this window was the same thing as typing print m, but apparently not. What exactly is the difference? What is the print statement doing that gets me m̥ instead of u'm\u0325'?

It's hard for my lazy-rear end fingers to type print segment.symbol all the time, and I'd like a proper printout when I type just segment. What do I need to fix?


edit: and apparently my problems extend to forum posting too...that 'm-with-a-dot-underneath' didn't show up properly here either, but at least you can still tell there are two different things getting printed.

FoiledAgain fucked around with this message at 00:48 on Apr 12, 2013

onionradish
Jul 6, 2006

That's spicy.
I spent a day and a half fighting a similar "problem" and had myself convinced I didn't understand Unicode either. My code was actually fine -- the problem was the output console (Windows Powershell). Try running the code in IDLE, or writing the output to a file and see if you're getting the value you expect. It may be your output console that doesn't understand Unicode, not you.

From IDLE:
>>> m=u'm\u0325'
>>> print m


edit: ^^ the M-dot doesn't show when it's enclosed in a 'code' block on the forum

FoiledAgain
May 6, 2007

onionradish posted:

I spent a day and a half fighting a similar "problem" and had myself convinced I didn't understand Unicode either. My code was actually fine -- the problem was the output console (Windows Powershell). Try running the code in IDLE, or writing the output to a file and see if you're getting the value you expect. It may be your output console that doesn't understand Unicode, not you.

Yeah, I should have noticed that - printing to file has never been a problem. I'm running this in PyScripter, if that means anything to anyone. edit: and I tested this out with IDLE and it works fine. So the problem is not me. *whew*. Thanks!

I found this too:

code:
>>>import sys
>>>sys.getdefaultencoding()
'ascii'
>>>sys.stdout.encoding
'ascii'
There's no sys.setdefaultencoding(), and trying to assign something different to sys.stdout.encoding didn't seem to have any effect.

FoiledAgain fucked around with this message at 01:18 on Apr 12, 2013

Smarmy Coworker
May 10, 2008

by XyloJW

DARPA posted:

It sounds like your application isn't looping. You might need something like:
Python code:
def main():
    while RUNNING:
        do_your_program_stuff()
        sleep(for_some_time)
edit: It looks like pika's connection.start_consuming() should block indefinitely, so you don't need to write your own while loop. Are you creating the pika connection prior to entering the DaemonContext? python-daemon will close all open file handles (including sockets) which will mess up a preexisting pika connection.

Huh.
Actually yes! I opened the connection and channels and whatnot in __init__ so that is most likely the problem. I had no idea python-daemon did that.

I will test things out.

Dren
Jan 5, 2001

Pillbug
When you're dealing with Unicode strings you can do the encoding to ASCII (or whatever your terminal's encoding is) before you print. This will allow you to manage the errors. See http://docs.python.org/2/howto/unicode.html for more information. I'm pretty sure that when you use 'print' str() gets called on your object, and in 2.x str only does ASCII. So consider that too. Maybe what you want with repr() is to directly return self.symbol so that no transcoding is performed.

QuarkJets
Sep 8, 2008

Is there a handy but thorough list of advantages gained by using new-styled classes in Python 2.X? I know a few of the advantages, like being able to user super, but I'd like to have a whole list handy to show to a coworker

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Descriptors, being able to use type(X) instead of X.__class__, metaclasses, __new__, and more

Smarmy Coworker
May 10, 2008

by XyloJW

ARACHNOTRON posted:

Huh.
Actually yes! I opened the connection and channels and whatnot in __init__ so that is most likely the problem. I had no idea python-daemon did that.

I will test things out.

Okay this code worked with a different program and does not work with this one. The only difference is I already had a list of the _id's I wanted (there were only 25 as opposed to 2500) and could create a DB connection in the M class.

Output:
code:
sudo python report_collection_daemon.py start

got to while
in while
And then it stops, no .pid file is made anywhere, doing python .py stop gives an error because it isn't running anymore.

Python code:
class App():
        def __init__(self):
                self.stdin_path = '/dev/null'
                self.stdout_path = '/dev/tty'
                self.stderr_path = '/dev/ttr'
                self.pidfile_path = '/tmp/foo.pid'
                self.pidfile_timeout = 5

        def run(self):
                connection = MongoClient('localhost', 27017)
                db = connection.demo
                mlist = db.m.find()
                print 'got to while'
                while True:
                        print "in while"
                        for m in mlist:
                                I = M(connection)
                                I.report(m._id)
                                print 'test'
                        print "2500 reports complete"
                        time.sleep(3600)


app = App()
daemon_runner = runner.DaemonRunner(app)
daemon_runner.do_action()
E:
anyway, completely unrelated, does code like this work?
Python code:
tuples = [(1, 2), (3, 4), (5, 6), (7, 8)]
firstlist = [t[0] for t in tuples]

>> firstlist
   [1, 3, 5, 7]
I realized I can test this out myself and it does.

Is it generally a cool thing that cool people do, though?

Smarmy Coworker fucked around with this message at 16:07 on Apr 12, 2013

DARPA
Apr 24, 2005
We know what happens to people who stay in the middle of the road. They get run over.

ARACHNOTRON posted:

And then it stops, no .pid file is made anywhere, doing python .py stop gives an error because it isn't running anymore.

Python code:
self.stderr_path = '/dev/ttr'
Looks like you have a typo (at least I don't have and have never seen /dev/ttr). You're routing standard error output to a nonexistent endpoint which explains why it might be dying without showing a message.

Smarmy Coworker
May 10, 2008

by XyloJW
Interestingly that is the path most of the examples had in them.

I looked and yeah there is totally no ttr in /dev/, but then what is the correct path?

Adbot
ADBOT LOVES YOU

Smarmy Coworker
May 10, 2008

by XyloJW
Haha wow thanks. I just routed it to stdout and

code:
got to while
in while
Traceback (most recent call last):
  File "report_collection_daemon.py", line 63, in <module>
    daemon_runner.do_action()
  File "/usr/local/lib/python2.7/dist-packages/python_daemon-1.6-py2.7.egg/daemon/runner.py", line 189, in do_action
    func(self)
  File "/usr/local/lib/python2.7/dist-packages/python_daemon-1.6-py2.7.egg/daemon/runner.py", line 134, in _start
    self.app.run()
  File "report_collection_daemon.py", line 55, in run
    M.report(m._id)
AttributeError: 'dict' object has no attribute '_id'
pymongo docs apparently lied to me.

  • Locked thread