[Trac] Re: OT: python for automating tasks, Was: Re: [Trac] Re: Global trac.ini not effective after upgrade to 0.11
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Noah Kantrowitz skrev 23-06-2008 21:56: | | On Jun 23, 2008, at 3:54 PM, Noah Kantrowitz wrote: | | | On Jun 23, 2008, at 3:41 PM, Eirik Schwenke wrote: | | -BEGIN PGP SIGNED MESSAGE- | Hash: SHA1 | | Noah Kantrowitz skrev 23-06-2008 16:54: | | On Jun 23, 2008, at 5:28 AM, Jani Tiainen wrote: | | So I need to do it by hand to all about 60 of my trac configs.. :D | | | | I wouldn't say it more flexible while upgrading, when creating | new | | instances it might be more flexible. | | | | for f in `ls /var/trac` | | do | | echo -e '\n[inherit]\nfile = /usr/share/trac/conf/trac.ini\n' | / | | var/trac/$f | | done | | Indeed. And I imagine most people running 60 parallel instances of | trac would | have a posix shell available. | | However, does anyone know of a reasonable package that would | allow a | similarly short example in python, that remained somewhat portable ? | | I'm not looking for something like ipython, the defunct pysh or | pythonShell -- | just some helpful filesystem iterators that aren't quite as verbose | as os.path.* | | Maybe a utility package that would the above be done in some | reasonably | intuitive 5-6 lines of python. | | Any ideas? | | Using IPython: | | for file in iglob('/var/trac/*/conf/trac.ini'): | open(file, 'a').write('\n[inherit].') | | Apparently the normal glob.glob works fine too here (I just like ipipe | stuffs). Hm, as I just commented off-list to someone else, I guess what I'm really missing is something like: import find for file in find(/var/trac,iname=trac.ini): ~ with open(file, 'a') as f: ~f.writelines([[inherit], blah=something]) (or. better yet, a nice appendline()/appendlines()-convenience method on all file objects that allows for doing the same thing (ie equivalent to the shell operator): for file in find(/var/trac,iname=trac.ini): ~ file.appendlines([[inherit], blah=something]) But I suppoose the meme i was missing was glob and/or os.walk. So coding around the lack of a find module: import os for root, files, dirs in os.walk(/var/trac): ~ for file in files: ~if file.lower() == trac.ini: ~ with open(os.path.join(root,file), a) as f: ~f.writelines([[inherit], blah=something]) I suppose I can live with glob and os.walk -- but it's a bit painful that os.walk returns only names as strings, and that there are no reasonable file/path objects (note the main reason that this is necessary is of course the fact that not all os' agree on path separators and/or mountpoints/driveletters). Still a python find-module seems like a good (and pretty simple) idea. Best regards, - -- ~ .---. Eirik Schwenke [EMAIL PROTECTED] ( NSD ) Harald Hårfagresgate 29Rom 150 ~ '---' N-5007 Bergentlf: (555) 889 13 ~ GPG-key at pgp.mit.edu Id 0x8AA3392C -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIYMaFxUW7FIqjOSwRAv+bAKC+eE+MeLkXa/zISCjXs466B3hsWQCfRCAk jzk9MU9OJiutQgeRgeAuxNg= =Hfxa -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: OT: python for automating tasks, Was: Re: [Trac] Re: Global trac.ini not effective after upgrade to 0.11
On Jun 24, 2008, at 6:03 AM, Eirik Schwenke wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Noah Kantrowitz skrev 23-06-2008 21:56: | | On Jun 23, 2008, at 3:54 PM, Noah Kantrowitz wrote: | | | On Jun 23, 2008, at 3:41 PM, Eirik Schwenke wrote: | | -BEGIN PGP SIGNED MESSAGE- | Hash: SHA1 | | Noah Kantrowitz skrev 23-06-2008 16:54: | | On Jun 23, 2008, at 5:28 AM, Jani Tiainen wrote: | | So I need to do it by hand to all about 60 of my trac configs.. :D | | | | I wouldn't say it more flexible while upgrading, when creating | new | | instances it might be more flexible. | | | | for f in `ls /var/trac` | | do | | echo -e '\n[inherit]\nfile = /usr/share/trac/conf/trac.ini \n' | / | | var/trac/$f | | done | | Indeed. And I imagine most people running 60 parallel instances of | trac would | have a posix shell available. | | However, does anyone know of a reasonable package that would | allow a | similarly short example in python, that remained somewhat portable ? | | I'm not looking for something like ipython, the defunct pysh or | pythonShell -- | just some helpful filesystem iterators that aren't quite as verbose | as os.path.* | | Maybe a utility package that would the above be done in some | reasonably | intuitive 5-6 lines of python. | | Any ideas? | | Using IPython: | | for file in iglob('/var/trac/*/conf/trac.ini'): | open(file, 'a').write('\n[inherit].') | | Apparently the normal glob.glob works fine too here (I just like ipipe | stuffs). Hm, as I just commented off-list to someone else, I guess what I'm really missing is something like: import find for file in find(/var/trac,iname=trac.ini): ~ with open(file, 'a') as f: ~f.writelines([[inherit], blah=something]) (or. better yet, a nice appendline()/appendlines()-convenience method on all file objects that allows for doing the same thing (ie equivalent to the shell operator): for file in find(/var/trac,iname=trac.ini): ~ file.appendlines([[inherit], blah=something]) But I suppoose the meme i was missing was glob and/or os.walk. So coding around the lack of a find module: import os for root, files, dirs in os.walk(/var/trac): ~ for file in files: ~if file.lower() == trac.ini: ~ with open(os.path.join(root,file), a) as f: ~f.writelines([[inherit], blah=something]) I suppose I can live with glob and os.walk -- but it's a bit painful that os.walk returns only names as strings, and that there are no reasonable file/path objects (note the main reason that this is necessary is of course the fact that not all os' agree on path separators and/or mountpoints/driveletters). Still a python find-module seems like a good (and pretty simple) idea. See `iwalk | filter`. --Noah --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: OT: python for automating tasks, Was: Re: [Trac] Re: Global trac.ini not effective after upgrade to 0.11
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Noah Kantrowitz skrev 24-06-2008 14:13: | On Jun 24, 2008, at 6:03 AM, Eirik Schwenke wrote: | Noah Kantrowitz skrev 23-06-2008 21:56: | On Jun 23, 2008, at 3:54 PM, Noah Kantrowitz wrote: | On Jun 23, 2008, at 3:41 PM, Eirik Schwenke wrote: | Noah Kantrowitz skrev 23-06-2008 16:54: | On Jun 23, 2008, at 5:28 AM, Jani Tiainen wrote: (... tidying up a bit ...) #posix shell solution - noah for f in `ls /var/trac` do ~ echo -e '\n[inherit]\nfile = /usr/share/trac/conf/trac.ini\n'\ ~var/trac/$f done | [D]oes anyone know of a reasonable package that would | allow asimilarly short example in python, that remained somewhat | portable ? | | I'm not looking for something like ipython, the defunct pysh or | pythonShell -- | just some helpful filesystem iterators that aren't quite as | verbose as os.path.* (...) | import os | | for root, files, dirs in os.walk(/var/trac): | ~ for file in files: | ~if file.lower() == trac.ini: | ~ with open(os.path.join(root,file), a) as f: | ~f.writelines([[inherit], blah=something]) | | (...) | Still a python find-module seems like a good (and pretty simple) idea. | | See `iwalk | filter`. I did have a look at ipipe (http://ipython.scipy.org/moin/UsingIPipe), but in some ways i think it's the wrong solution to the right problem. While borrowing syntax from the shell might be a nice fit for working from within ipython - it feels a bit bolted on -- especially when working from say an install script. I'm perfectly happy using bash, awk, grep and find on the command line -- and ipython is a fine python debug/eval/test-tool; but adding that interface to python directly leads down the path to perl IMNHO. Python already has list comprehensions, map, lamda and filter -- I'd much rather have a first rate object/graph mapping of the filesystem in a way that feels natural to standard python, than a half-baked shell meta-language (not that there's anything wrong with a half-baked meta-languages in and of themselves, but I'd rather have one obvious and suitably lazy way to do things, while still being readable :-) Anyway, thanks for all the input -- I'll leave this alone until I get around to implementing a correct solution ;-) Best regards, - -- ~ .---. Eirik Schwenke [EMAIL PROTECTED] ( NSD ) Harald Hårfagresgate 29Rom 150 ~ '---' N-5007 Bergentlf: (555) 889 13 ~ GPG-key at pgp.mit.edu Id 0x8AA3392C -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIYQNkxUW7FIqjOSwRAlx2AJ4qe5lqtrm6AI9E/11bVrKHnopd0wCgknKA X2IVJyBlS700wh6ybC0rcR0= =XRxi -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: OT: python for automating tasks, Was: Re: [Trac] Re: Global trac.ini not effective after upgrade to 0.11
On 24/06/2008, Eirik Schwenke [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Noah Kantrowitz skrev 24-06-2008 14:13: | On Jun 24, 2008, at 6:03 AM, Eirik Schwenke wrote: | Noah Kantrowitz skrev 23-06-2008 21:56: | On Jun 23, 2008, at 3:54 PM, Noah Kantrowitz wrote: | On Jun 23, 2008, at 3:41 PM, Eirik Schwenke wrote: | Noah Kantrowitz skrev 23-06-2008 16:54: | On Jun 23, 2008, at 5:28 AM, Jani Tiainen wrote: (... tidying up a bit ...) #posix shell solution - noah for f in `ls /var/trac` do ~ echo -e '\n[inherit]\nfile = /usr/share/trac/conf/trac.ini\n'\ ~var/trac/$f done | [D]oes anyone know of a reasonable package that would | allow asimilarly short example in python, that remained somewhat | portable ? | | I'm not looking for something like ipython, the defunct pysh or | pythonShell -- | just some helpful filesystem iterators that aren't quite as | verbose as os.path.* (...) | import os | | for root, files, dirs in os.walk(/var/trac): | ~ for file in files: | ~if file.lower() == trac.ini: | ~ with open(os.path.join(root,file), a) as f: | ~f.writelines([[inherit], blah=something]) | | (...) | Still a python find-module seems like a good (and pretty simple) idea. | | See `iwalk | filter`. I did have a look at ipipe (http://ipython.scipy.org/moin/UsingIPipe), but in some ways i think it's the wrong solution to the right problem. While borrowing syntax from the shell might be a nice fit for working from within ipython - it feels a bit bolted on -- especially when working from say an install script. I'm perfectly happy using bash, awk, grep and find on the command line -- and ipython is a fine python debug/eval/test-tool; but adding that interface to python directly leads down the path to perl IMNHO. Python already has list comprehensions, map, lamda and filter -- I'd much rather have a first rate object/graph mapping of the filesystem in a way that feels natural to standard python, than a half-baked shell meta-language (not that there's anything wrong with a half-baked meta-languages in and of themselves, but I'd rather have one obvious and suitably lazy way to do things, while still being readable :-) Anyway, thanks for all the input -- I'll leave this alone until I get around to implementing a correct solution ;-) Best regards, - -- ~ .---. Eirik Schwenke [EMAIL PROTECTED] ( NSD ) Harald Hårfagresgate 29Rom 150 ~ '---' N-5007 Bergentlf: (555) 889 13 ~ GPG-key at pgp.mit.edu Id 0x8AA3392C -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIYQNkxUW7FIqjOSwRAlx2AJ4qe5lqtrm6AI9E/11bVrKHnopd0wCgknKA X2IVJyBlS700wh6ybC0rcR0= =XRxi -END PGP SIGNATURE- -- cheers, -ambrose The 'net used to be run by smart people; now many sites are run by idiots. So SAD... (Sites that do spam filtering on mails sent to the abuse contact need to be cut off the net...) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: OT: python for automating tasks, Was: Re: [Trac] Re: Global trac.ini not effective after upgrade to 0.11
On Jun 23, 2008, at 3:41 PM, Eirik Schwenke wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Noah Kantrowitz skrev 23-06-2008 16:54: | On Jun 23, 2008, at 5:28 AM, Jani Tiainen wrote: | So I need to do it by hand to all about 60 of my trac configs.. :D | | I wouldn't say it more flexible while upgrading, when creating new | instances it might be more flexible. | | for f in `ls /var/trac` | do | echo -e '\n[inherit]\nfile = /usr/share/trac/conf/trac.ini\n' / | var/trac/$f | done Indeed. And I imagine most people running 60 parallel instances of trac would have a posix shell available. However, does anyone know of a reasonable package that would allow a similarly short example in python, that remained somewhat portable ? I'm not looking for something like ipython, the defunct pysh or pythonShell -- just some helpful filesystem iterators that aren't quite as verbose as os.path.* Maybe a utility package that would the above be done in some reasonably intuitive 5-6 lines of python. Any ideas? Using IPython: for file in iglob('/var/trac/*/conf/trac.ini'): open(file, 'a').write('\n[inherit].') If you don't have the IPipe__ extension loaded by default you also need: from IPython import ipapi ipapi.get().ex(from ipipe import *) __ http://ipython.scipy.org/moin/UsingIPipe --Noah --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: OT: python for automating tasks, Was: Re: [Trac] Re: Global trac.ini not effective after upgrade to 0.11
On Jun 23, 2008, at 3:54 PM, Noah Kantrowitz wrote: On Jun 23, 2008, at 3:41 PM, Eirik Schwenke wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Noah Kantrowitz skrev 23-06-2008 16:54: | On Jun 23, 2008, at 5:28 AM, Jani Tiainen wrote: | So I need to do it by hand to all about 60 of my trac configs.. :D | | I wouldn't say it more flexible while upgrading, when creating new | instances it might be more flexible. | | for f in `ls /var/trac` | do | echo -e '\n[inherit]\nfile = /usr/share/trac/conf/trac.ini\n' / | var/trac/$f | done Indeed. And I imagine most people running 60 parallel instances of trac would have a posix shell available. However, does anyone know of a reasonable package that would allow a similarly short example in python, that remained somewhat portable ? I'm not looking for something like ipython, the defunct pysh or pythonShell -- just some helpful filesystem iterators that aren't quite as verbose as os.path.* Maybe a utility package that would the above be done in some reasonably intuitive 5-6 lines of python. Any ideas? Using IPython: for file in iglob('/var/trac/*/conf/trac.ini'): open(file, 'a').write('\n[inherit].') Apparently the normal glob.glob works fine too here (I just like ipipe stuffs). --Noah --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: OT: python for automating tasks, Was: Re: [Trac] Re: Global trac.ini not effective after upgrade to 0.11
Eirik Schwenke wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Noah Kantrowitz skrev 23-06-2008 16:54: | On Jun 23, 2008, at 5:28 AM, Jani Tiainen wrote: | So I need to do it by hand to all about 60 of my trac configs.. :D | | I wouldn't say it more flexible while upgrading, when creating new | instances it might be more flexible. | | for f in `ls /var/trac` | do | echo -e '\n[inherit]\nfile = /usr/share/trac/conf/trac.ini\n' / | var/trac/$f | done Indeed. And I imagine most people running 60 parallel instances of trac would have a posix shell available. However, does anyone know of a reasonable package that would allow a similarly short example in python, that remained somewhat portable ? I'm not looking for something like ipython, the defunct pysh or pythonShell -- just some helpful filesystem iterators that aren't quite as verbose as os.path.* Maybe a utility package that would the above be done in some reasonably intuitive 5-6 lines of python. Any ideas? (I can already hear someone snickering perl ;-) I hate to do this, it's almost contra ban around here, but oh well.. cd $TRACPARENT; echo -e \n[inherit]\nfile = /usr/share/trac/conf/trac.ini\n | ruby -ne 'Dir[**/trac.ini].each {|fn| File.open(fn, a) {|f| f.puts($_}}' /me ducks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: OT: python for automating tasks, Was: Re: [Trac] Re: Global trac.ini not effective after upgrade to 0.11
Eirik Schwenke kirjoitti: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Noah Kantrowitz skrev 23-06-2008 16:54: | On Jun 23, 2008, at 5:28 AM, Jani Tiainen wrote: | So I need to do it by hand to all about 60 of my trac configs.. :D | | I wouldn't say it more flexible while upgrading, when creating new | instances it might be more flexible. | | for f in `ls /var/trac` | do | echo -e '\n[inherit]\nfile = /usr/share/trac/conf/trac.ini\n' / | var/trac/$f | done Indeed. And I imagine most people running 60 parallel instances of trac would have a posix shell available. Not necessarily :D remember we have Windows users here too... However, does anyone know of a reasonable package that would allow a similarly short example in python, that remained somewhat portable ? I'm not looking for something like ipython, the defunct pysh or pythonShell -- just some helpful filesystem iterators that aren't quite as verbose as os.path.* Maybe a utility package that would the above be done in some reasonably intuitive 5-6 lines of python. Any ideas? Not sure about ideas, but it really feels stupid to do something manually since Trac upgrade process already automatically, without asking added some other stuff (like workflow) in trac.ini file. Why an earth it couldn't repeat old behaviour and add that two lines automatically - specially since that information is available. And IIRC Trac has always upgraded itself correctly. This might be a true problem when 0.11 hits Linux distro packages and upgrade doesn't happen automatically... Also some of my trac.ini:s are getting old (first ones are from 0.8.4 and only upgraded since) it would be nice to have .ini beautifier that would read, rearrange and rewrite trac.ini to match latest things... (This was just an idea...) -- Jani Tiainen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---
[Trac] Re: OT: python for automating tasks, Was: Re: [Trac] Re: Global trac.ini not effective after upgrade to 0.11
Jani Tiainen wrote: (snip) Not sure about ideas, but it really feels stupid to do something manually since Trac upgrade process already automatically, without asking added some other stuff (like workflow) in trac.ini file. Why an earth it couldn't repeat old behaviour and add that two lines automatically - specially since that information is available. And IIRC Trac has always upgraded itself correctly. I agree that the Trac 0.11 installation should do this trac.ini format conversion transparently to the end-user. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Trac Users group. To post to this group, send email to trac-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~--~~~~--~~--~--~---