|
tehk posted:Is there a popular extension framework for python? Something like MEF/MonoAddins/JPF/Boost-Extension. What's wrong with just storing all that metadata in a dictionary?
|
# ? May 27, 2010 14:00 |
|
|
# ? Jun 13, 2024 06:16 |
|
tehk posted:Is there a popular extension framework for python? Something like MEF/MonoAddins/JPF/Boost-Extension. A dictionary in the module would do fine. Also, metaclasses and plugin systems are made for each other, just in case you had not looked into them.
|
# ? May 27, 2010 16:04 |
|
deimos posted:A dictionary in the module would do fine. Also, metaclasses and plugin systems are made for each other, just in case you had not looked into them. The issue with that is I need to import the plug-in to get the dictionary, which brings me back to square one so it is not much different then what I am currently doing. Plugs could do bad things in whilst I am just importing them to get the metadata. I want to have that data available before I import the module. Most other projects which have python extensions use this approach as well. I just remembered the configparser module which should solve my problems for now. However, I would still like to know if any of the frameworks out there are any good. edit: vvv That is true I can't, but I would also prefer if a module was not loaded unless it was enabled for performance issues. Err also if the plug-in is enabled then I do not care so much about it doing 'bad things'. I just don't want them doing them when the user is under the impression that they are disabled. tehk fucked around with this message at 17:34 on May 27, 2010 |
# ? May 27, 2010 16:34 |
|
tehk posted:The issue with that is I need to import the plug-in to get the dictionary, which brings me back to square one so it is not much different then what I am currently doing. Plugs could do bad things in whilst I am just importing them to get the metadata. I want to have that data available before I import the module. Most other projects which have python extensions use this approach as well. Any problem with just doing something like __import__("plugin", fromlist=["metadata"]) e: whoops, yes, ignore me. But if you can't trust your plugins not to do 'bad things' in the main body, how can you trust them not to do 'bad things' in the correct methods?
|
# ? May 27, 2010 17:10 |
|
What's a good module for writing a parser in? I found this old blogpost which lists too many to test out and try individually: http://nedbatchelder.com/text/python-parsers.html I basically have a structured text-format that I'll need to turn into Python objects. Each line is a record, and the lines following can be sub-records or new records themselves.
|
# ? Jun 2, 2010 18:31 |
|
Carthag posted:What's a good module for writing a parser in? I found this old blogpost which lists too many to test out and try individually: http://nedbatchelder.com/text/python-parsers.html The answer to this is usually, in order, PyParsing and then PLY. (Meaning, try PyParsing, if that doesn't seem like it can do it or you don't like it, then try PLY.)
|
# ? Jun 2, 2010 19:07 |
|
bitprophet posted:The answer to this is usually, in order, PyParsing and then PLY. (Meaning, try PyParsing, if that doesn't seem like it can do it or you don't like it, then try PLY.) Thanks I'll check them out
|
# ? Jun 2, 2010 19:09 |
|
What's a good way to strip out XML tags but not their content? I'm trying to convert Tomboy/Gnote notes to another format (iPhone notes.db) and I need to remove the tags from the text itself. I can do it with regexes of course, but that seems so crude and volatile. lxml has strip_tags, but it's broken in the version in the Ubuntu repos.
|
# ? Jun 2, 2010 19:11 |
|
Threep posted:lxml has strip_tags, but it's broken in the version in the Ubuntu repos. Then get a different version?
|
# ? Jun 2, 2010 19:30 |
|
Avenging Dentist posted:Then get a different version? I figured it was a common task and there'd be an easy solution.
|
# ? Jun 2, 2010 19:40 |
|
Threep posted:Would prefer a solution that works on Ubuntu without messing with custom packages (pip is also way out of date) since it would make support a pain otherwise. u''.join(your_lxml_etree.xpath('//text()'))
|
# ? Jun 2, 2010 19:55 |
|
It's been a long time since I've worked with XML in any non-trivial way, but it sounds like it'd be pretty trivial to do with XSLT, and I believe lxml can process XSLT. The bonus here is that XSLT might be able to do a decent amount of the processing for you. The downside is that you'd be writing XSLT code, though. And just to work around a bug in a library in Ubuntu.
|
# ? Jun 2, 2010 20:00 |
|
Habnabit posted:u''.join(your_lxml_etree.xpath('//text()'))
|
# ? Jun 2, 2010 20:27 |
|
Is there any "easy" way to work with videos in Python? I'm trying to do some editing work on YouTube videos (watermarks, replace sections) and cant find a good library to do this. Pymedia doesn't support FLVs and even then the process is converting the whole vid to imgs and then putting it back together. Seems like there should be an easier way... Anyone know of one?
|
# ? Jun 4, 2010 05:16 |
|
ninjawtf posted:Is there any "easy" way to work with videos in Python? I'm trying to do some editing work on YouTube videos (watermarks, replace sections) and cant find a good library to do this. Pymedia doesn't support FLVs and even then the process is converting the whole vid to imgs and then putting it back together. Seems like there should be an easier way... Anyone know of one? It looks like PyMedia hasn't been updated since 2006, which would explain why it doesn't support FLV. Check out pyffmpeg which is a Python wrapper for the ffmpeg libavcodec and libavformat libraries (which underpin VLC and ffdshow among others). It doesn't look very complete, but it looks like it can decode video frames and I assume you could manage the rest from there. Also, if you're using Windows, you might want to consider Avisynth as an alternative to Python for this job. Avisynth is a scripting language specifically designed for manipulating video files. You could probably accomplish what you want with just a few lines of Avisynth code.
|
# ? Jun 4, 2010 07:23 |
|
So I've been using python for a while to do mostly scientific computing. It's been quite handy due to its increased flexibility over matlab and I've been able to make some pretty decent GUI so other people can utilize my code with minimal training, and its been great to work with basically just a text editor and the terminal on OSX. However, I now have a need to use an external SDK. Specifically, I need to be able to write a program that will use Canon's "EDSDK" in order to remotely control and gather data from a camera. I have no idea at all how this works. The OSX version of the EDSDK I downloaded seems to have no actual method files. Instead it comes as a 'framework', which seems to mean its usable with XCode and I suppose written in Objective-C. Is it possible to access such a thing with Python? Would I be better off downloading their Windows version of the EDSDK which I think consists of .dll files. I have no more experience with those than I do with 'frameworks' but at least I've seen them in the directories of other programs. The main thing is that I'd like to use the Python files I've already generated in an app that will control this camera. Is this possible?
|
# ? Jun 4, 2010 22:08 |
|
Farrok posted:The main thing is that I'd like to use the Python files I've already generated in an app that will control this camera. Is this possible? You can do it (perhaps not well) with ctypes, which will let you talk with C and C-like libraries. There's also this but I don't know what the difference between EDSDK and CDSDK is: http://pypi.python.org/pypi/pycanon/0.9
|
# ? Jun 4, 2010 22:30 |
|
Avenging Dentist posted:You can do it (perhaps not well) with ctypes, which will let you talk with C and C-like libraries. There's also this but I don't know what the difference between EDSDK and CDSDK is: http://pypi.python.org/pypi/pycanon/0.9 Another option might be using gPhoto to control the camera. Either write your own bindings/wrapper or use the subprocess module to call the gphoto utility.
|
# ? Jun 4, 2010 22:43 |
|
I'm looking for a module that allows me to connect to a MySQL database. I've tried pymysql but it's bugged, so you can't SELECT more than one row (which sucks). Anyone have any good modules they wish to share?
|
# ? Jun 5, 2010 00:05 |
|
Yakattak posted:I'm looking for a module that allows me to connect to a MySQL database. I've tried pymysql but it's bugged, so you can't SELECT more than one row (which sucks). Anyone have any good modules they wish to share? The standard answer is mysqldb. I've been needing something in pure python, so I've been using MySQL Connector/Python.
|
# ? Jun 5, 2010 00:14 |
|
Thermopyle posted:The standard answer is mysqldb. I've been needing something in pure python, so I've been using MySQL Connector/Python. If you're only working with a handful of tables, then that works. Otherwise, use SQLAlchemy.
|
# ? Jun 5, 2010 00:16 |
|
Avenging Dentist posted:You can do it (perhaps not well) with ctypes, which will let you talk with C and C-like libraries. There's also this but I don't know what the difference between EDSDK and CDSDK is: http://pypi.python.org/pypi/pycanon/0.9 I had seen that, but unfortunately the difference in the two SDKs lies in which cameras are supported. Mine is not supported by CDSDK =/. Cpt.Wacky posted:Another option might be using gPhoto to control the camera. Either write your own bindings/wrapper or use the subprocess module to call the gphoto utility. Tried this, too, but I don't know what to do with the error I'm getting. Running gphoto2 --auto-detect and it finds my camera. However, it can't seem to actually access it. Every time I try a command that actually tries to get through the usb connection to the camera returns the following error: Error (-53: 'Could not claim the USB device'). This appears to have a been a bug in previous versions specific to a linux kernel and I can't find any info about fixing it in OSX. Without being able to use lsusb in the terminal, I don't know how to approach debugging the issue as suggested from those folks that found it in linux. I thought maybe it was as simple as requiring root access, but sudo doesn't help either.
|
# ? Jun 5, 2010 00:18 |
|
Thermopyle posted:The standard answer is mysqldb. I've been needing something in pure python, so I've been using MySQL Connector/Python. When I do setup.py install, it keeps saying: code:
|
# ? Jun 5, 2010 00:21 |
|
Yakattak posted:
I don't know the answer in any case, but you should probably specify which of the two packages I mentioned you're trying.
|
# ? Jun 5, 2010 00:32 |
|
Thermopyle posted:I don't know the answer in any case, but you should probably specify which of the two packages I mentioned you're trying. MySQL Connector/Python, I tried both the zip and tar (I knew if one didn't work, the other wouldn't but I thought I'd try).
|
# ? Jun 5, 2010 00:35 |
|
Yakattak posted:I'm looking for a module that allows me to connect to a MySQL database. I've tried pymysql but it's bugged, so you can't SELECT more than one row (which sucks). Anyone have any good modules they wish to share? oursql is pretty much the best thing that's out there right now. The top of that link has a whole list of reasons why you should use it over mysqldb. myconnpy is a bit of a mess. I've been considering rewriting it from scratch with support for twisted.
|
# ? Jun 5, 2010 00:52 |
|
Farrok posted:I had seen that, but unfortunately the difference in the two SDKs lies in which cameras are supported. Mine is not supported by CDSDK =/. Is there anything using the camera, either directly or in the background? That error sounds to me like it might mean "device in use".
|
# ? Jun 5, 2010 01:01 |
|
MaberMK posted:If you're only working with a handful of tables, then that works. Otherwise, use SQLAlchemy. SQLAlchemy is totally distinct from a driver. SQLAlchemy is a framework/toolkit/whatever, it *uses* MySQLDb (and most other PEP249 compliant drivers).
|
# ? Jun 5, 2010 01:20 |
|
Habnabit posted:oursql is pretty much the best thing that's out there right now. The top of that link has a whole list of reasons why you should use it over mysqldb. I take it your a (the?) dev of oursql? Is it pure python?
|
# ? Jun 5, 2010 01:23 |
|
king_kilr posted:SQLAlchemy is totally distinct from a driver. SQLAlchemy is a framework/toolkit/whatever, it *uses* MySQLDb (and most other PEP249 compliant drivers). And as of sqlalchemy 0.6, it supports oursql as well! Thermopyle posted:I take it your a (the?) dev of oursql? The only dev. It's written almost entirely in cython, with a bit of C and some code generation stuff in python.
|
# ? Jun 5, 2010 01:26 |
|
Habnabit posted:And as of sqlalchemy 0.6, it supports oursql as well! Hmm hopefully you can answer this for me. When I try to install oursql it can't find mysql_config. Where should I be able to find this?
|
# ? Jun 5, 2010 01:51 |
|
How does oursql compare to MySQL Connector/Python?
|
# ? Jun 5, 2010 02:02 |
|
MEAT TREAT posted:How does oursql compare to MySQL Connector/Python? I've never heard of ANYONE using MySQL Connector/Python. HTH.
|
# ? Jun 5, 2010 03:00 |
|
Yakattak posted:Hmm hopefully you can answer this for me. When I try to install oursql it can't find mysql_config. Where should I be able to find this? It comes with the mysql development libraries. If you're on windows or ubuntu, there's binaries available. Otherwise, install your platform's version of libmysqlclient-dev. MEAT TREAT posted:How does oursql compare to MySQL Connector/Python? myconnpy doesn't use libmysql at all; it's a total rewrite from scratch in pure python. AFAIK, it's not fully-functional yet, and still doesn't offer any options for asynchronous queries. The quality of the python code isn't really the best, either. I don't know if myconnpy uses parameterized queries like oursql does, so it might not be able to do server-side cursors either.
|
# ? Jun 5, 2010 03:37 |
|
Habnabit posted:The only dev. It's written almost entirely in cython, with a bit of C and some code generation stuff in python. Too bad. That makes it not usable with things like greenlet or eventlet. king_kilr posted:I've never heard of ANYONE using MySQL Connector/Python. Then you're not reading this thread since I mention using it several posts up.
|
# ? Jun 5, 2010 05:04 |
|
Thermopyle posted:Too bad. That makes it not usable with things like greenlet or eventlet. Eventlet? I'm so, so sorry. But yeah, for you folks using real eventloops, I'm definitely considering rewriting myconnpy for usability with twisted. I think twisted recently got an async postgres driver, too.
|
# ? Jun 5, 2010 06:37 |
|
Habnabit posted:Eventlet? I'm so, so sorry. Twisted? I'm so, so sorry.
|
# ? Jun 5, 2010 08:12 |
|
Captain Capacitor posted:Twisted? I'm so, so sorry. Well, hey, at least my code is linear.
|
# ? Jun 5, 2010 08:22 |
|
Habnabit posted:It comes with the mysql development libraries. If you're on windows or ubuntu, there's binaries available. Otherwise, install your platform's version of libmysqlclient-dev. I used MacPorts to install MySQL5 and I do infact have mysql_config in the MySQL dirs, yet pip doesn't seem to find it and it completely errors out.
|
# ? Jun 5, 2010 14:33 |
|
|
# ? Jun 13, 2024 06:16 |
|
Yakattak posted:I used MacPorts to install MySQL5 and I do infact have mysql_config in the MySQL dirs, yet pip doesn't seem to find it and it completely errors out. If you used macports, it's probably called mysql_config5 instead of mysql_config. There's a section in the oursql docs for what to do with a differently-named mysql_config.
|
# ? Jun 5, 2010 16:27 |