code logs -> 2010 -> Fri, 25 Jun 2010< code.20100624.log - code.20100626.log >
--- Log opened Fri Jun 25 00:00:46 2010
00:01 AnnoDomini [annodomini@Nightstar-49021e91.adsl.tpnet.pl] has quit [Ping timeout: 121 seconds]
00:02 Derakon [Derakon@Nightstar-1ffd02e6.ucsf.edu] has quit [[NS] Quit: Leaving]
00:07
< Tarinaky>
Interesting.
00:08
< Tarinaky>
I just typoed and entered cd # instead of cd ~
00:08
< Tarinaky>
And it went to my homedir.
00:08 You're now known as TheWatcher[T-2]
00:08
< Tarinaky>
That's quite odd.
00:14 You're now known as TheWatcher[zZzZ]
00:14
< celticminstrel>
Not really.
00:15
< celticminstrel>
# is the comment character, and cd with no argument changes to the home directory.
00:16
< Tarinaky>
Ahh.
00:17
< Tarinaky>
Duh.
00:17
< Tarinaky>
For some reason I was thinking of the Windows version where without arguments it prints the cwd.
00:17
< Tarinaky>
At least, iirc.
00:17
< celticminstrel>
Does it? I did not know that.
00:17
< Tarinaky>
I have a vague recollection it did.
00:17
< Tarinaky>
I don't remember :/
00:18
< Tarinaky>
What -is- the Windows equiv to cd?
00:18
< celticminstrel>
cd
00:18
< celticminstrel>
:P
00:19
< Tarinaky>
That'd be obvious.
00:19
< celticminstrel>
Hehe.
00:20
< Stalker>
It prints something?
00:21
< Tarinaky>
I thought it did.
00:22 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
00:22 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Client closed the connection]
00:23 RichardBarrell [mycatverbs@Nightstar-58acb782.cable.virginmedia.com] has joined #code
00:25 Rhamphoryncus [rhamph@Nightstar-bbc709c4.abhsia.telus.net] has joined #code
00:27 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
00:28 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Client closed the connection]
00:30 Serah [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
00:35 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
00:40 RichardBarrell [mycatverbs@Nightstar-58acb782.cable.virginmedia.com] has quit [[NS] Quit: Is sleep time now.]
01:10 Attilla [Attilla@Nightstar-e28e7906.threembb.co.uk] has quit [Ping timeout: 121 seconds]
01:14 Derakon [Derakon@Nightstar-5213d778.ca.comcast.net] has joined #code
01:14 mode/#code [+o Derakon] by Reiver
01:21 Orthia [orthianz@Nightstar-9ac6cb1e.xnet.co.nz] has joined #code
01:23
< celticminstrel>
What's the recommended action to take when my IRC-bot finds itself disconnected? It seems to die in netsplits sometimes.
01:25 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed]
01:29
< ToxicFrog>
flush state as appropriate and reconnect
01:29
< celticminstrel>
What's appropriate for flushing state?
01:31
< ToxicFrog>
Depends on your bot.
01:31
< celticminstrel>
Well, generally speaking.
01:32
<@Derakon>
Any state that cannot be guaranteed to be accurate when you reconnect.
01:32
< celticminstrel>
...I suppose flushing the list of responses it was waiting on would be sensible.
01:55
< celticminstrel>
Speaking of the list of responses, they are stored in a dictionary, and I made a mistake of using the waiting function as a key...
01:55 * celticminstrel is trying to figure out a better way.
01:59
< celticminstrel>
Though... does a generator function generate a different iterator each time it is called? Maybe using the function as a key doesn't have the disadvantage I thought it did.
02:00 * celticminstrel tests and determines that it doesn't.
02:00
< ToxicFrog>
Depends on the generator.
02:01
< celticminstrel>
It's one of those functions that uses the "yield" keyword.
02:01
< ToxicFrog>
Also, if the dictionary only contains pending responses, why not just clear the whole thing?
02:01
< celticminstrel>
Hm?
02:02
< ToxicFrog>
Ok, backing up: why is the fact that the waiting function is a key a problem?
02:02
<@Derakon>
TF: yeah, he's saying he'd like to improve the dict in general.
02:02
< celticminstrel>
Well, my assumption was that if the waiting function was called twice in quick succession that the second call's waiting info would overwrite the first's.
02:03
< celticminstrel>
But then I tried it, and it looks like it doesn't.
02:04 Orthia [orthianz@Nightstar-9ac6cb1e.xnet.co.nz] has quit [Connection reset by peer]
02:12 Orthia [orthianz@Nightstar-9ac6cb1e.xnet.co.nz] has joined #code
02:12 Orthia [orthianz@Nightstar-9ac6cb1e.xnet.co.nz] has quit [Client closed the connection]
02:20 Orthia [orthianz@Nightstar-9ac6cb1e.xnet.co.nz] has joined #code
02:22 Orth [orthianz@Nightstar-e7cb9685.xnet.co.nz] has joined #code
02:25 Orthia [orthianz@Nightstar-9ac6cb1e.xnet.co.nz] has quit [Ping timeout: 121 seconds]
02:31 Orth [orthianz@Nightstar-e7cb9685.xnet.co.nz] has quit [Client closed the connection]
02:39 Orthia [orthianz@Nightstar-e7cb9685.xnet.co.nz] has joined #code
03:40 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [[NS] Quit: Z?]
04:00 Orthia [orthianz@Nightstar-e7cb9685.xnet.co.nz] has quit [Client closed the connection]
04:02 Syloqs-AFH [Syloq@NetworkAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
04:02 Syloqs_AFH [Syloq@NetworkAdministrator.Nightstar.Net] has joined #code
04:03 Syloqs_AFH is now known as Syloqs-AFH
04:07 Orthia [orthianz@Nightstar-e7cb9685.xnet.co.nz] has joined #code
04:31 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
04:42 Orthia [orthianz@Nightstar-e7cb9685.xnet.co.nz] has quit [Client closed the connection]
04:49 Orthia [orthianz@Nightstar-e7cb9685.xnet.co.nz] has joined #code
04:49 Syloqs-AFH [Syloq@NetworkAdministrator.Nightstar.Net] has quit [Client closed the connection]
04:53 Syloqs_AFH [Syloq@NetworkAdministrator.Nightstar.Net] has joined #code
04:55 Syloqs_AFH is now known as Syloqs-AFH
05:36 Orthia [orthianz@Nightstar-e7cb9685.xnet.co.nz] has quit [Ping timeout: 121 seconds]
05:40 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: KABOOM! It seems that I have exploded. Please wait while I reinstall the universe.]
05:40 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
06:17 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
06:28 Orthia [orthianz@Nightstar-3fbe7c0d.xnet.co.nz] has joined #code
06:31 Orth [orthianz@Nightstar-337c6f64.xnet.co.nz] has joined #code
06:32 Orthia [orthianz@Nightstar-3fbe7c0d.xnet.co.nz] has quit [Ping timeout: 121 seconds]
06:34 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has joined #code
06:35 Orth [orthianz@Nightstar-337c6f64.xnet.co.nz] has quit [Ping timeout: 121 seconds]
06:53 Derakon is now known as Derakon[AFK]
07:11 AnnoDomini [annodomini@Nightstar-9845665e.adsl.tpnet.pl] has joined #code
07:11 mode/#code [+o AnnoDomini] by Reiver
08:22 Attilla [Attilla@Nightstar-13e9ddc7.threembb.co.uk] has joined #code
08:22 mode/#code [+o Attilla] by Reiver
08:54 You're now known as TheWatcher
08:57 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has quit [Connection reset by peer]
09:01 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has joined #code
09:10 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has quit [Client closed the connection]
09:15 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has joined #code
09:21 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has quit [Client closed the connection]
09:25 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has joined #code
09:46 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has quit [Client closed the connection]
09:55 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has joined #code
09:56 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has quit [Client closed the connection]
10:01 cpux [Moo@Nightstar-20a84089.dyn.optonline.net] has quit [Ping timeout: 121 seconds]
10:03 Orthia [orthianz@Nightstar-9d4b1b8c.xnet.co.nz] has joined #code
10:07 Rhamphoryncus [rhamph@Nightstar-bbc709c4.abhsia.telus.net] has quit [Client exited]
10:31 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
10:33 Netsplit *.net <-> *.split quits: @Attilla, @Derakon[AFK], @Vornicus, PinkFreud, Tarinaky, crem, ToxicFrog, Thaqui, Syloqs-AFH, Stalker, (+2 more, use /NETSPLIT to show all of them)
10:34 Netsplit over, joins: Thaqui, @Vornicus, PinkFreud, Syloqs-AFH, Alek, crem, Tarinaky, @Attilla, Stalker, Zed
10:34 mode/#code [+o Syloqs-AFH] by Reiver
10:34 Vornicus-Latens [vorn@ServerAdministrator.Nightstar.Net] has joined #code
10:34 mode/#code [+o Vornicus-Latens] by Reiver
10:34 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
10:34 Vornicus-Latens is now known as Vornicus
10:35 Netsplit over, joins: ToxicFrog
10:35 mode/#code [+o ToxicFrog] by Reiver
11:05 Attilla [Attilla@Nightstar-13e9ddc7.threembb.co.uk] has quit [[NS] Quit: ]
11:09 Tarinaky [Tarinaky@Nightstar-70cbe1b0.adsl.virginmedia.net] has quit [Operation timed out]
11:15 Vornicus is now known as Vornicus-Latens
11:23 Tarinaky [Tarinaky@Nightstar-1ca8efa9.adsl.virginmedia.net] has joined #code
12:22 shade_of_cpux [Moo@Nightstar-20a84089.dyn.optonline.net] has joined #code
12:22 shade_of_cpux is now known as cpux
12:27 cpux is now known as shade_of_cpux
12:42 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Client closed the connection]
14:00 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
14:43 Zed [Zed@Nightstar-e4835f03.or.comcast.net] has quit [Client closed the connection]
15:02 Tarinaky [Tarinaky@Nightstar-1ca8efa9.adsl.virginmedia.net] has quit [Ping timeout: 121 seconds]
15:16 Tarinaky [Tarinaky@Nightstar-a165a26a.adsl.virginmedia.net] has joined #code
15:19 RichardBarrell [mycatverbs@Nightstar-ab5d9327.cable.virginmedia.com] has joined #code
15:27 RichardBarrell [mycatverbs@Nightstar-ab5d9327.cable.virginmedia.com] has quit [Connection closed]
15:27 RichardBarrell [mycatverbs@Nightstar-ab5d9327.cable.virginmedia.com] has joined #code
15:28 RichardBarrell [mycatverbs@Nightstar-ab5d9327.cable.virginmedia.com] has quit [[NS] Quit: ERC Version 5.3 (IRC client for Emacs)]
15:55 SmithKurosaki [Smith@Nightstar-bbece9a8.dsl.teksavvy.com] has quit [Connection closed]
16:24 RichardBarrell [mycatverbs@Nightstar-ab5d9327.cable.virginmedia.com] has joined #code
16:34 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [Client closed the connection]
16:35 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has joined #code
16:35 mode/#code [+o ToxicFrog] by Reiver
16:42 RichardBarrell [mycatverbs@Nightstar-ab5d9327.cable.virginmedia.com] has quit [Operation timed out]
16:49 Derakon [Derakon@Nightstar-1ffd02e6.ucsf.edu] has joined #code
16:49 mode/#code [+o Derakon] by Reiver
16:49
<@Derakon>
Question for people who are a bit more adept at *nix than I am.
16:50
<@Derakon>
I have a program that opens an SSH connection to a server. I want to invoke a program on that server, and then disconnect the SSH connection before it finishes, leaving it to run in the background.
16:50
<@Derakon>
Is screen my only way to achieve this, or is there some other way to detach the program from the session?
16:50
< celticminstrel>
command & disown %1
16:50
<@Derakon>
Ahh.
16:50
< celticminstrel>
Though screen may be a better choice if you want to later...
16:51
<@Derakon>
No, I won't need to reattach later.
16:51
< celticminstrel>
...be able to look at the program's output.
16:51
< celticminstrel>
Okay then.
16:51
<@Derakon>
The program's output is in the form of new files that get created.
16:51
< celticminstrel>
(Typing one-handed is slow...)
16:51
<@Derakon>
Heh.
16:51
<@Derakon>
(The program is in fact just a shell script that's invoking another program in serial with each file that is to be processed)
16:56
< celticminstrel>
Well, disown is what I did with my IRC bot before someone alerted me to the utility of screen.
17:06 Rhamphoryncus [rhamph@Nightstar-bbc709c4.abhsia.telus.net] has joined #code
17:06
<@Derakon>
Hey, Rhamph.
17:06
<@Derakon>
Got a Python question for you, actually.
17:06
< Rhamphoryncus>
Ahoy.
17:06
<@Derakon>
How do I get this to do what I want, cleanly? http://pastebin.starforge.co.uk/311
17:07
<@Derakon>
(the original use case has a reason for both lambda and call(), incidentally, even though call() is redundant here)
17:11 * Rhamphoryncus scratches his head
17:12
<@Derakon>
Basically I want the lambda to bind to the current value of "thing", not what it is at the end of the loop.
17:12
< Rhamphoryncus>
oh, the closure on the lambda is failing, yeah
17:12
< Rhamphoryncus>
I can think of a few ways
17:13
<@Derakon>
The way I had to settle for was having a map of ID numbers to functions instead of a map of functions to things that call them. Not as elegant IMO.
17:13
< Rhamphoryncus>
One is to treat it similar to a decorator, calling an outer function (passing in thing) which returns an inner function, the latter will have the outer's closure
17:14
< Rhamphoryncus>
A common hack is to pass it as a default value for a keyword argument. lambda thing=thing: call(thing)
17:14
<@Derakon>
...
17:14
<@Derakon>
Okay then.
17:14
< Rhamphoryncus>
A more obscure hack would be to use functools.partial
17:15
<@Derakon>
Which is Python's currying?
17:15
< Rhamphoryncus>
yes
17:16
<@Derakon>
I take it the keyword approach basically works by creating a new forced scope which assigns "thing" in the outer scope to "thing" in the inner scope?
17:16 Syloqs-AFH [Syloq@NetworkAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
17:17
< Rhamphoryncus>
The scopes already exist, but yeah. Evaluating the default argument is done in the outer scope (where the function is defined). Then, when called, thing will exist as an argument in the inner scope
17:17 Syloqs_AFH [Syloq@NetworkAdministrator.Nightstar.Net] has joined #code
17:18
<@Derakon>
See, Python scopes confuse me because nothing ever goes out of scope except at the end of a function that is not contained within another function or a class.
17:18 Syloqs_AFH is now known as Syloqs-AFH
17:18
<@Derakon>
s/or a class//
17:22
< Rhamphoryncus>
classes don't have a closure
17:22
<@Derakon>
Yeah, hence the redaction. My brain's not quite in gear yet.
17:22
< Rhamphoryncus>
oh :)
17:23
< celticminstrel>
Classes do have a scope, sort of...
17:23
< Rhamphoryncus>
Conceptually, but in python it deliberately does not use the closure mechanism. You have to use attribute lookups
17:31
<@Derakon>
Thanks for the help, Rhamph.
17:31
< Rhamphoryncus>
np
17:32 * celticminstrel rather likes decorators...
17:33 Rhamphoryncus [rhamph@Nightstar-bbc709c4.abhsia.telus.net] has quit [Client exited]
17:58
<@ToxicFrog>
<3 pattern matching
17:58
<@ToxicFrog>
Source.fromInputStream(System.in).getLines.foreach {
17:59
< celticminstrel>
...language?
17:59
< celticminstrel>
That looks Java-like...
17:59
<@ToxicFrog>
case Command(fields @ _*) => System.out.println("\t{ " + fields.mkString(",\n\t\t") + "\n\t},")
17:59
< celticminstrel>
That, however, does not.
17:59
<@ToxicFrog>
case line:String => System.out.print(line)
17:59
<@ToxicFrog>
}
17:59
<@ToxicFrog>
Scala.
17:59
< celticminstrel>
Ah.
18:00
<@Derakon>
...what is it, a re-indenter?
18:01
<@ToxicFrog>
It explodes stuff of the form { foo, bar, baz, moby } into
18:01
<@ToxicFrog>
{ foo
18:01
<@ToxicFrog>
bar,
18:01
<@ToxicFrog>
baz,
18:01
<@ToxicFrog>
moby
18:01
<@ToxicFrog>
},
18:01
<@Derakon>
Ah.
18:01
<@ToxicFrog>
Thus turning 2MB of C files into something the three-way merge tool won't choke and die on.
18:02
<@ToxicFrog>
(at present it's seeing every line of consequence as having changed, since one field in each of these initializers has been altered, which is giving it problems in lining up the files)
18:03
<@Derakon>
Youch.
18:05
<@ToxicFrog>
Yeah.
18:05
<@ToxicFrog>
Anyways, the <3 here comes from the use of Command, which is a regex
18:05
<@ToxicFrog>
Command(fields @ _*) binds 'fields' to a Seq[String] containing all of the captures made by that regex on the input.
18:06
<@ToxicFrog>
If the input doesn't match Command, neither does that case clause.
18:06
<@Derakon>
Funky.
18:06
<@ToxicFrog>
Earlier I was doing Commands(long, min, security, kind ...etc...) =>, but it turns out it's easier to treat it as an iterable for the purposes of output.
18:09
<@Derakon>
...weird, when I disown a process, OSX Terminal still says it'll get killed when I close the terminal window, but it doesn't.
18:10 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
18:20 RichardBarrell [mycatverbs@Nightstar-ab5d9327.cable.virginmedia.com] has joined #code
18:24
< RichardBarrell>
It's sad when you find yourself grepping a software package for the string "try:" because you know that the people who wrote it were too dumb to actually understand error handling, and that every try/catch block therefore almost certainly represents a serious bug.
18:25
< Tarinaky>
Isn't Exception Handling meant to be used in 'Exceptional Circumstances'?
18:25
< Tarinaky>
And not... you know... just mildly annoying Thursday Afternoon Circumstances?
18:26
< Namegduf>
Varies by language.
18:26
< RichardBarrell>
I'm working on a piece of software whose authors didn't understand the idea that it's generally not a good idea to silently swallow exceptions.
18:26
< Namegduf>
Not Python, at the least.
18:27
< Namegduf>
Nor Java.
18:27
< Tarinaky>
Namegduf: I didn't know it did :/
18:27
< Namegduf>
Unless you consider a failure to open a file truly "exceptional"
18:27
< Tarinaky>
Well, yes.
18:27
<@Vornicus-Latens>
It sort of is. Without that you can't really continue at all.
18:27
< Tarinaky>
Unexceptional is if there're no errors anywhere.
18:28
< Tarinaky>
A malformed file is 'exceptional'.
18:28
< Tarinaky>
It's not the normal state of being.
18:28
< Tarinaky>
Well... Unexceptional perhaps means something a bit more than that.
18:28
< Tarinaky>
But I can't quite articulate it.
18:29
< Tarinaky>
But an unexceptional situation isn't, really, an error since it should be entirely normal and predictable :/
18:30
< Tarinaky>
Sorry if I'm rambling a bit. I'm a touch drunk.
18:30
< Tarinaky>
>.> <.< >.>
18:31
<@ToxicFrog>
Java and Python seem to use exceptions for everything, IME
18:31
< RichardBarrell>
Tarinaky: you should totally go install FreeBSD right now!
18:31
<@ToxicFrog>
Lua (by convention) uses them only for programmer/VM errors - type mismatch, out of memory, etc - and returns (nil,error) pairs for environmental errors like file-not-found.
18:32
< Tarinaky>
RichardBarrell: I don't get your joke :/
18:32
< RichardBarrell>
Tarinaky: that means that you probably don't spend much time reading XKCD. That is a good thing.
18:32
< Tarinaky>
I've read every xkcd ever unfortunately.
18:32
< Tarinaky>
Well.
18:32
< Tarinaky>
Except the ones he's not released yet.
18:32
< Tarinaky>
But w/e.
18:33
< Tarinaky>
And give or take about 6 hours for the RSS feed to update >.> <.< >.>
18:33
< RichardBarrell>
ToxicFrog: AIUI, exception handling isn't anywhere near as expensive in Python as it is in Java, at least compared to the habitual slowness of the Python interpreter.
18:33
< Tarinaky>
But I've successfully updated Arch Linux while drunk off my face.
18:33
< Tarinaky>
So, yeah.
18:34
< Tarinaky>
With the exception of once when I was too drunk to enter my own root password correctly.
18:34
< RichardBarrell>
Tarinaky: yeah, well, I can type "yes | pacman -Syu" in my *sleep*.
18:34
< Tarinaky>
Welll... User password actually.
18:34
< Tarinaky>
>.> <.< >.>
18:34
< Tarinaky>
RichardBarrell: That's the wrong way of doing it.
18:34
< Tarinaky>
RichardBarrell: Also, that breaks thing.
18:34
< Tarinaky>
*things
18:35
< Tarinaky>
You want --noconfirm
18:35
< RichardBarrell>
Python's throw-an-exception-any-time-anything-goes-wrong idiom works quite nicely in frameworks that manage transactions for you. The framework installs an exception handler that'll abort the current transaction, and then most of your code can run blithely ahead, simply allowing exceptions to bubble if or when they ever come up.
18:35
< RichardBarrell>
Tarinaky: I had forgotten what the option was called. :)
18:36
< Tarinaky>
But yeah.
18:36
< Tarinaky>
I've fixed config files while drunk.
18:36
< Tarinaky>
Admittedly I was sobering up by then though.
18:36 * Tarinaky shrugs.
18:36
< Tarinaky>
I dunno if that adds or subtracts geek kudos.
18:36
< Tarinaky>
I suspect it depends which rules we're playing against.
18:37
< Namegduf>
I think it means you need to take one drink.
18:38
< Tarinaky>
Well I've run out.
18:38
< Tarinaky>
So neener neener.
18:47 * Derakon eyes the string he just wrote.
18:47
<@Derakon>
'./%s/%s %s "%s" %s'
18:50
< celticminstrel>
That's a lot of format characters.
18:51
<@Derakon>
The first two are for the constants for a directory name and program name; the third is a program to have the program invoke; the fourth is the arguments to pass to that program, and the fifth is a space-delimited list of files to operate on.
18:55
< Tarinaky>
The description sounds hackish.
18:55
< Tarinaky>
So tbh the result looks relatively elegant.
18:55
< Tarinaky>
So good job!
18:55
<@Derakon>
Heh.
18:56
<@Derakon>
The goal here is to background the process of invoking a specific program multiple times with the same set of arguments.
18:56
<@Derakon>
So I'm invoking a shell script to do the repeat invocations, and can background that.
18:56
<@Derakon>
The shell script is generalized so I can use the same script for multiple functions that each have similar invocation patterns.
18:56
< Tarinaky>
Ah. Shell script.
18:56
< RichardBarrell>
Derakon: what language are you writing in?
18:56
<@Derakon>
Python.
18:56
<@Derakon>
Well, and shell.
18:58
< RichardBarrell>
Derakon: then I implore you, import pipes, and use pipes.quote in order to quote things for shells, rather than just surrounding the string with double quotes.
18:58
< celticminstrel>
Would it be nicer to write './{dir}/{prog} {invoke} "{args}" {files}'.format(...)?
18:58
< celticminstrel>
Oh wait, shell script?
18:58
< celticminstrel>
The preceding applies only to Python.
18:58
<@Derakon>
Rich: explain to me the significance?
18:59
< RichardBarrell>
Derakon: pipes.quote will handle things like filenames with " in the middle correctly. '"%s"' % filename, won't.
18:59
< celticminstrel>
Yeah.
18:59
<@Derakon>
Ah.
18:59
<@Derakon>
So it's like escaping MySQL stringns.
18:59
<@Derakon>
Er, strings.
18:59
< RichardBarrell>
Yes.
18:59
<@Derakon>
Okay, thanks.
19:00
< RichardBarrell>
No, thank you.
19:00 * RichardBarrell endeavours to make the world a slightly less buggy place, and is grateful for your cooperation in his epic quest. ;)
19:00
< celticminstrel>
Also, shell double-quoted strings are parsed, sort of like in PHP. So there are a lot of things that would need escaping.
19:01
<@Derakon>
Heh.
19:01
<@Derakon>
In practice, this is a sufficiently limited use case that I doubt there'd be problems.
19:01
<@Derakon>
But why be sloppy?
19:01
< RichardBarrell>
Good attitude. :)
19:02
< RichardBarrell>
Oh, that reminds me. Did you know that Windows' SMB implementation doesn't check the filenames passing through it properly?
19:04
< RichardBarrell>
So if you mount a Windows share using smbfs on a Unix, you can create files that Windows users have extreme trouble touching, because Unixes allow *any* character in filenames except for '/' and '\0', whereas Windows has a whole list of characters that you're not supposed to use.
19:05
< RichardBarrell>
Found that one out by accident when copying music from my laptop running Linux to my Windows desktop. Filenames based on song titles, song titles with apostrophes in them, chaos! Good times.
19:05 * Derakon eyes this line:
19:05
<@Derakon>
" ".join([pipes.quote(name) for name in fileNames]))
19:06
<@Derakon>
<3 list comprehensions
19:06
< RichardBarrell>
Looks safe and correct to me. List comprehensions *are* really quite nice.
19:16 RichardBarrell [mycatverbs@Nightstar-ab5d9327.cable.virginmedia.com] has quit [Operation timed out]
19:33 crem [moo@Nightstar-8ca3eea7.adsl.mgts.by] has quit [Connection reset by peer]
19:39 crem [moo@Nightstar-8ca3eea7.adsl.mgts.by] has joined #code
19:40
<@Derakon>
Hrm, disowning appears to be breaking the process anyway.
19:40
<@Derakon>
I wrote a test script that outputs a number once per second, invoked it and redirected to a file, then disowned it and closed the window.
19:40
<@Derakon>
ps claims it's still running, but nothing's showing up in the file.
19:41
< celticminstrel>
Maybe it needs to flush the changes to disk?
19:41
<@Derakon>
Hm, possibly. I keep forgetting Python's ridiculously aggressive output buffering.
19:42
< celticminstrel>
Well, if it's a Python script, you could open the file in append mode...
19:43
<@Derakon>
Okay, that seems to be working.
19:43
<@Derakon>
Celticminstrel: that would require creating filehandles in Python instead of just printing and using a redirect.
19:44
<@Derakon>
So now the question is, when I disown the remote process and disconnect my SSH session, why does the remote process halt?
19:44
< celticminstrel>
Does it halt?
19:45
<@Derakon>
It doesn't show up in ps, ergo it has halted.
19:45
< celticminstrel>
Okay.
19:45
< celticminstrel>
What exactly did you do?
19:46
<@Derakon>
cd dir && /bin/sh invoker.sh arg1 arg2 arg3 & disown %1
19:47
<@Derakon>
Then I closed the SSH connection.
19:47
< celticminstrel>
I assume you got some kind of [1] ... message?
19:49
<@Derakon>
As a matter of fact, no...
19:49
< celticminstrel>
...
19:50
< celticminstrel>
Okay, try everything except the "disown %1" bit, including the &
19:50
< celticminstrel>
But don't close the SSH.
19:51
< Namegduf>
You are using "ps x" rather than just "ps", right?
19:51 Vornicus-Latens is now known as Vornicus
19:51
<@Derakon>
Namegduf: ps -efwww
19:52
<@Derakon>
Celticminstrel: still nothing; I suspect that content may not be making it to the "stdout" and "stderr" objects that the paramiko library returns when I use exec_command on the SSH client object.
19:53
< celticminstrel>
The [1] ... message is printed by the shell to indicate that a process has been moved to the background.
19:53
<@Derakon>
Yeah, so is there in fact a shell here?
19:53
<@Derakon>
That's what I don't know.
19:54
< celticminstrel>
Um, if you're in SSH, you're in a shell. Though, it's possible you might not be in bash, I suppose.
19:54
< Namegduf>
False.
19:54
< celticminstrel>
I dunno if regular sh supports these things...
19:54
< Namegduf>
SSH can run another command rather than a shell.
19:55
< celticminstrel>
What other command would it run?
19:55
<@Derakon>
SSH is just sending bits through a socket, securely.
19:55
< Namegduf>
Any.
19:55
< celticminstrel>
Well, usually it runs a shell, right?
19:55
< Namegduf>
It's a user option, not a server option.
19:55
<@McMartin>
Isn't SCP basically using cat as your shell?
19:56
< Namegduf>
You know you can specify a command at the end of an SSH command?
19:56
< Namegduf>
That. :P
20:01
<@Derakon>
Hrm...seems like nohup should accomplish a similar goal as disowning, and it works fine when I do it interactively, but again I'm getting a canceled process when I try to do it from within the Python program.
20:02
<@Derakon>
Here's the code snippet: http://pastebin.starforge.co.uk/318
20:03
<@Derakon>
The "Stdout follows:" and "Stderr follows:" lines have no following content. I don't even get the message from nohup about it appending output to nohup.out.
20:13 Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has joined #code
20:25
<@Derakon>
Hm. screen isn't even installed on the remote computer.
20:26
<@Derakon>
Annoyingly, screen seems to be the standard "worked for me" response to "how do I daemonize with paramiko".
20:28
<@Derakon>
Everyone also suggests trying nohup but no word on getting it to actually work.
20:29
<@ToxicFrog>
Should just be 'nohup command'
20:31
<@Derakon>
Oh, it works fine in a normal interactive terminal.
20:31
<@Derakon>
It's not behaving itself in paramiko though.
20:32 * Derakon ponders writing a second shell script to wrap the first shell script with nohup.
20:49
<@Derakon>
Nope, that doesn't work either. >.<
20:56
<@Derakon>
So wait, I have a shell script that, when invokes, runs another script with nohup. So the first script exits immediately. Then I close my SSH connection. Why the hell is the second script then not executing?
21:15 Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has quit [Ping timeout: 121 seconds]
21:25 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
21:46
<@McMartin>
D:
21:46
<@McMartin>
[tangent] Tale says, "Now I want a OS called "yo mama" if only for error reports like "This won't run on yo mama""
21:46
<@McMartin>
[tangent] vaporware says, "Yo mama so fat and buggy, the Colonel panics every time she walks into KFC."
21:46
<@McMartin>
[tangent] DorianX says (to vw), "Thank you"
21:46
<@McMartin>
[tangent] DorianX says, "I was gonna waste the whole afternoon trying to come up with one"
21:46
<@McMartin>
[tangent] baf says, "Yo Mama's default filesystem is FAT32."
21:46
<@McMartin>
[tangent] Roger says, "Ain't nobody wanna use Yo Momma's backdoor"
21:46 * Derakon facepalms.
21:47
<@AnnoDomini>
Hahaha.
21:48 * Derakon mutters imprecations at paramiko.
21:48
<@Derakon>
You're so good at everything else; why can't you just detach a process for me?
21:48
<@Derakon>
;_;
21:58
<@Derakon>
Come to think, the "screen" approach (screen -d -m command) wouldn't close the screen when the program exits anyway, would it? So I'd have a bunch of screen processes sitting around on the server.
21:58
<@ToxicFrog>
public XUserUserGroupUserRolesUserRole[] userRoles;
21:58
<@Derakon>
...
21:58
<@AnnoDomini>
What.
22:00
<@McMartin>
Beatings
22:00
<@jerith>
Derakon: "screen command" kills the screen when the command is done.
22:01 * jerith used to use that quite a lot.
22:01
<@Derakon>
Jerith: ah.
22:01
< Namegduf>
Yeah
22:01
<@Derakon>
Well, I still don't have access to screen, but maybe that can be rectified, since nothing else seems to work.
22:07
<@Derakon>
Hm...made a small test program that uses disown, and it seems to work OK.
22:12
< PinkFreud>
Derakon: not until screen decides that crashing is the ay to go
22:12
< PinkFreud>
er, way
22:12
< PinkFreud>
sadly, it does that on occasion
22:13 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Client closed the connection]
22:19
< celticminstrel>
What sort of occasions?
22:19 * Namegduf has never seen it happen
22:24
< PinkFreud>
Namegduf: you may not have experienced it, but you *have* seen it happen.
22:24
< PinkFreud>
my irssi session lives under screen. Every so often, it dies when I have to nuke an unresponsive screen. :P
22:25
< Namegduf>
Are you sure you're not just sending an XOFF or something?
22:25
< PinkFreud>
quite. nothing will wake it back up.
22:25
< PinkFreud>
and once one window croaks, other windows start following suit.
22:26
< Namegduf>
Huh.
22:26
< PinkFreud>
yeah, it's rather annoying. fortunately, it's not something which happens terribly often.
22:37 RichardBarrell [mycatverbs@Nightstar-6846d4dc.cable.virginmedia.com] has joined #code
22:43
< celticminstrel>
ohhhhh.....
22:44 * celticminstrel was trying to find a file with find/locate, and forgot about case sensitivity.
22:44
<@Derakon>
Argh, why do I always have so much trouble with output redirects?
22:45
<@Derakon>
If in a shell script, I do somecommand 2>&1 >> log.txt, how can the output of that command not be captured to log.txt?
22:45
<@Derakon>
Here's the shell script: http://pastebin.starforge.co.uk/319
22:45
<@Derakon>
Line 17 is the one that's not getting captured.
22:46
<@Derakon>
(and 16 is an anomaly caused by bad copy&paste)
22:47
< Tarinaky>
Derakon: I -think- that you can't do that.
22:47
< Tarinaky>
You can't redirect 2 to two palces.
22:47
<@Derakon>
The echo lines work fine. Why shouldn't this one?
22:47
< Tarinaky>
*places
22:48
< Tarinaky>
The 2>~&1 is different.
22:48
<@Derakon>
Also, >> log.txt 2>&1 has the same bad result.
22:48
< Tarinaky>
Remove the 2>&1
22:48
< Tarinaky>
I think it'll get captured then.
22:48
< Tarinaky>
:x
22:48
<@Derakon>
Nope.
22:49
< Tarinaky>
Oh.
22:49
< Tarinaky>
Dunno then :/
22:50
<@Derakon>
Oh wait, I wasn't updating the script I was running; I was updating my local copy instead.
22:53
< Tarinaky>
>.<
22:57 Stalker [Z@2C3C9C.B2A300.F245DE.859909] has joined #code
23:06
<@Derakon>
...hm, okay, now it's working.
23:11 Rhamphoryncus [rhamph@Nightstar-bbc709c4.abhsia.telus.net] has joined #code
23:40 shade_of_cpux is now known as cpux
--- Log closed Sat Jun 26 00:00:47 2010
code logs -> 2010 -> Fri, 25 Jun 2010< code.20100624.log - code.20100626.log >