Activity Graph

Page 1 of 2 | Next »


[21:42:38] dgarstang: has joined #ruby
[21:43:21] dgarstang: Ruby makes me sad. Trying to get response from rest-client gem. If I use puts resp.body I see it but if I do puts ">>> #{resp.body} <<<" i don't. Why?
[21:46:01] dgarstang: and why does puts.resp show me {"modified":"EA7SNK"} whereas puts.resp['modified'] shows me nothing. How can that be!?
[21:49:37] dgarstang: konsolebox: RestClient::Response
[21:50:36] dgarstang: It looks like I have to JSON.parse(resp) ...
[21:53:02] dgarstang: Quit: WeeChat 1.8


[16:54:39] dgarstang: has joined #ruby
[16:54:55] dgarstang: In rake, how would I invoke a task in the format namespace::job[args] ?
[16:57:17] dgarstang: matthewd: From inside the Rakefile tho
[16:57:58] dgarstang: matthewd: My rakefile is loading a list of tasks to build from a yaml file, and I need to execute each as if called from the command line
[16:58:17] dgarstang: matthewd ... except, they're being called from inside the Rakefile. Some sort of eval and invoke combo?
[16:59:31] dgarstang: matthewd: What's foo in this case if job is the job?
[17:00:16] dgarstang: matthewd: but it's being read as a single string, as if executed from the command line, in the format ns:job[args]
[17:00:38] dgarstang: matthewd: so, I guess Rake needs to call itself
[17:01:10] dgarstang: matthewd: I don't want to split the arguments out and parse as I want to keep generic in case the args change
[17:02:55] dgarstang: matthewd: That was it, thanks
[17:06:05] dgarstang: matthewd: ok, sort of worked, it seems that the Rakefile just stops after the first job
[17:07:58] dgarstang: matthewd: So, basically if the jobs are loaded from a yaml file, and with projects['projects'].each do |p| Rake.application.invoke_task(p) end... the first one runs fine but the second does not
[17:08:29] dgarstang: matthewd: It doesn't even try and execute the 2nd one, it just stops. If I replace the rake command with a simple puts(p) it shows both jobs
[17:09:58] dgarstang: So, it seems like when you use Rake.application.invoke_task(), execute doesn't return to the point it left off after it's finished
[17:12:03] dgarstang: matthewd: Yes?
[17:12:49] dgarstang: hm maybe it does
[17:13:28] dgarstang: matthewd: Ok, so the loop is executing twice. The second task returns an error but none of that output is displayed
[17:13:55] dgarstang: matthewd: ie If I run the task through rake, it shows errors, if it's run via the invoke, no output is shown. Weird
[17:15:01] dgarstang: matthewd: ok if I call the same task twice, ie a working one twice, same thing. Output is shown for the first one , but no output is shown for the 2nd one. I know its executing both because I put a puts statement after each in the loop
[17:15:20] dgarstang: jeez I dunno
[17:15:50] dgarstang: matthewd: Ok, so.. what if it's the same task with different arguments?
[17:16:09] dgarstang: Won't that run twice?
[17:16:21] dgarstang: matthewd: The yaml file has a list of projects to build
[17:17:09] dgarstang: matthewd: Ok, what's the right way to do this? How do you have a Rakefile iterate over a list of projects, and be able to build one or all depending on how it's called?
[17:18:44] dgarstang: If rake only ever executes a task once inside a Rakefile, I don't see how a Rakefile could build for multiple projects if the tasks are the same, but the args differ. This must be a common problem
[17:19:11] dgarstang: matthewd: you mean drive it from a script, which defeats the purpose of Rake
[17:19:27] dgarstang: or a second Rakefile, which I presume can call the other, seems hacky
[17:20:21] dgarstang: matthewd: There's a bazillion examples of rake tasks taking arguments
[17:24:00] dgarstang: matthewd: http://cobwwweb.com/4-ways-to-pass-arguments-to-a-rake-task
[17:27:50] dgarstang: matthewd: Build for a single project, with args, no problem. Building for ALL the projects, if so desired, how?
[17:29:13] dgarstang: matthewd: or, put anothe way, if you want to build for multiple projects, what drives that?
[17:29:35] dgarstang: matthewd: Stick the call to rake inside a shell script that iterates over them?
[17:32:07] dgarstang: matthewd: I wanted to have the ability to build specific projects if needed, and also the ability to build multiple based off a list. I don't want to build all in case there's an issue and it blocks everything else
[17:32:32] dgarstang: some idiot checks in something that breaks, ok, remove their project from the build list
[17:35:21] dgarstang: matthewd: Different rake tasks, same Rakefile
[18:25:29] dgarstang: Ping timeout: 246 seconds


[17:44:13] dgarstang: has joined #ruby
[17:45:06] dgarstang: Where can I find good examples of how to use the ruby aws sdk? Specifically I get to get cloudformation stack outputs. Theres a lot of examples for python boto3 but if you google the equivalent operatons for ruby, there's very very little except API references which makes it hard for people to start using it
[17:47:05] dgarstang: I mean, how do I even use this? http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/CloudFormation/StackOutput.html
[17:48:03] dgarstang: azggil: I've read it numerous times. "client = Aws::CloudFormation::StackOutput()" ... tried that, that doesn't work
[17:50:51] dgarstang: speakingcode: No, how do I do that? Where does that doc tell me how to do that?
[17:50:58] dgarstang: azggil: I found the v2 docs
[17:51:29] dgarstang: http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Types/DescribeStacksOutput.html
[17:51:35] dgarstang: ^ allegedly v2
[17:52:16] dgarstang: azggil: That's S3
[17:54:21] dgarstang: The doc at http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Types/DescribeStacksOutput.html has a link to http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Client.html#describe_stacks-instance_method but that doesn't tell me what the client should look for.
[17:54:37] dgarstang: speakingcode: yes but what comes before that?
[17:55:17] dgarstang: speakingcode: "client = Aws::CloudFormation::Client()
[17:55:21] dgarstang: ... doesn't work
[17:55:26] dgarstang: (that's whats at the top of the doc)
[17:55:51] dgarstang: speakingcode: No. I hate it, but I gotta use it
[17:56:59] dgarstang: tacking a .new on the end won't help, as it reports "undefined method `Client' for Aws::CloudFormation:Module (NoMethodError)"
[17:57:30] dgarstang: speakingcode: I've been doing python for 15 years. ruby makes my eyes bleed. Trust me, I've tried many many times and it just makes no sense to me
[17:58:08] dgarstang: apeiros: not sure where you got 6 months from, but I always struggle with the aws sdk for ruby. python is fine. there's docs and examples
[17:58:38] dgarstang: speakingcode: No, it's the ruby implementation of it
[17:59:17] dgarstang: speakingcode: Thanks.
[18:02:09] dgarstang: speakingcode: sure, python does the same thing. it's the ruby syntax that grates me
[18:02:28] dgarstang: speakingcode: in python it's foo = Object(...). In ruby it's a lot more complicated
[18:02:36] dgarstang: azggil: it's chef. Can't
[18:03:11] dgarstang: apeiros: you mean Aws::CloudFormation::Client.new()
[18:03:42] dgarstang: Don't suppose anyone knows the way to get cfn stack outputs via the sdk
[18:04:37] dgarstang: it's not clear (no examples) if I can just call a method on the Cfn object or if I have to dig down several object levels, which means trying to interpret that API doc
[18:05:21] dgarstang: speakingcode: cloudformation
[18:05:57] dgarstang: http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation.html
[18:07:08] dgarstang: well I got some sort of an object because I'm pretty sure I haven't assigned a module reference to a variable here
[18:07:25] dgarstang: choke: CloudFormation stacks have well defined outputs
[18:08:12] dgarstang: so it looks like the CloudFormation 'module' has a Stack class... which has an outputs attribute.... but how to get it...
[18:09:11] dgarstang: speakingcode: How do I get a Stack object from that?
[18:09:44] dgarstang: choke: yes I'm there, but that doesn't help me
[18:10:13] dgarstang: speakingcode: I don't want to call describe stacks do I? i just want to get outputs for a particular stack
[18:10:41] dgarstang: time to go update IAM. Ugh
[18:11:16] dgarstang: speakingcode: I think I'm good now, thanks.... until the next ruby eye bleed inducement
[20:46:57] dgarstang: Quit: WeeChat 1.3


[16:09:18] dgarstang: has joined #ruby
[16:09:50] dgarstang: In ruby, how can I test a variable, and if it's not set have it return false?
[16:11:25] dgarstang: adaedra: isn't false == defined?
[16:11:48] dgarstang: adaedra: In python, I can just test it. if it's nil or false, the conditional returns false, if it's true, it returns true
[16:12:46] dgarstang: adaedra: I want to put it in an if statement, so I need true/false
[16:13:10] dgarstang: adaedra: doesn't work. if I don't define it first, and I test it, I get an error
[16:14:47] dgarstang: adaedra: thanks
[22:53:49] dgarstang: Quit: WeeChat 1.3


[01:43:38] dgarstang: Ping timeout: 252 seconds
[02:10:19] dgarstang: has joined #ruby
[03:29:08] dgarstang: Ping timeout: 250 seconds
[03:32:02] dgarstang: has joined #ruby
[05:02:36] dgarstang: Ping timeout: 264 seconds


[23:01:20] dgarstang: has joined #ruby
[23:02:19] dgarstang: Been at this for hours. Trying to iterate over ec2 instances with ruby sdk. What do I do with a #<Aws::Resources::Collection:0x007fb53c7454e8>? how do I iterate it? I can't find ANY examples of this
[23:07:41] dgarstang: zenspider: instances.each { |x| puts x }
[23:07:53] dgarstang: zenspider: That barfs
[23:08:12] dgarstang: zenspider: I have no idea what to do with a Aws::Resources::Collection object
[23:08:46] dgarstang: zenspider: /Users/doug/.chefdk/gem/ruby/2.1.0/gems/aws-sdk-core-2.1.14/lib/aws-sdk-core/param_validator.rb:26:in `validate!': unexpected value at params[:filters][0][:instance_id] (ArgumentError)
[23:08:58] dgarstang: line 26 is a comment line for crying out loud
[23:09:44] dgarstang: baweaver: If I remove the instances.each { |x| puts x } (which comes after the filter), the error goes away
[23:10:17] dgarstang: baweaver: i don't know what that means. ruby doesn't proces lines in the order they appear?
[23:10:45] dgarstang: ACTION counts to 10 slowly
[23:11:38] dgarstang: ok, it's the filter. if I try and undertsand the rest my blood pressure will just go up
[23:12:33] dgarstang: I am curious though how a backtrace that points to a commented line is useful by any definition
[23:13:26] dgarstang: baweaver: That's not line 26. Line 26 is further down and a comment line
[23:14:08] dgarstang: baweaver: fine. I'm still wondering if ruby normally throws errors pointing to commented lines tho?
[23:16:14] dgarstang: zenspider: https://gist.github.com/anonymous/16f49735fd31e5e44f4e
[23:16:24] dgarstang: zenspider: line 15.
[23:16:31] dgarstang: line 15 is empty
[23:16:48] dgarstang: ah actually
[23:16:55] dgarstang: scrap that. it's just the badly formatted backtrace
[23:20:30] dgarstang: searching for an example of what filter syntax should look like...
[23:21:10] dgarstang: all I seem to get is library docs
[23:22:15] dgarstang: you'd think 'aws ec2 instances filter instance id ruby' on google would retrieve something
[23:22:45] dgarstang: Radar: yeah I know. i found that out, thanks
[23:23:21] dgarstang: baweaver: pretty sure I can
[23:24:48] dgarstang: baweaver: I've already got an intance id... i need to get the instance object so I can pull the launch time
[23:25:09] dgarstang: baweaver: i know I can filter by tags
[23:25:17] dgarstang: baweaver: the python api lets me filter by instance id
[23:29:04] dgarstang: how would one pull an instance object if one knows the instance id?
[23:29:16] dgarstang: please don't say pull them all and iterate over them all
[23:29:54] dgarstang: i think i am using that...
[23:31:20] dgarstang: hope it works with describe_auto_scaling_groups ...
[23:31:57] dgarstang: oh wait ^ scrap that
[23:33:35] dgarstang: baweaver: seems to work, thanks


[14:34:25] dgarstang: has joined #ruby
[14:34:36] dgarstang: Where can I find an example of how to set credentials for the aws sdk v2?
[14:35:47] dgarstang: apeiros: like here?
[14:35:57] dgarstang: apeiros: here? http://docs.aws.amazon.com/sdkforruby/api/index.html
[14:36:26] dgarstang: "ec2 = Aws::EC2::Resource.new(region:'us-west-2', credentials: credentials)" ... it doesn't say anywhere how to set the variable credentials
[14:36:56] dgarstang: I assumed it was hash... doesn't work, and if it IS a hash, what are the exact names of the keys supposed to be?
[14:37:24] dgarstang: apeiros: I prefer the ""ec2 = Aws::EC2::Resource.new(region:'us-west-2', credentials: credentials)" version
[14:37:42] dgarstang: So, again, in the use case of '"ec2 = Aws::EC2::Resource.new(region:'us-west-2', credentials: credentials)', how does one set credentials?
[14:38:11] dgarstang: apeiros: I prefer the alternatively documented version
[14:38:44] dgarstang: apeiros: the one your pasing is from Aws.config.update
[14:39:13] dgarstang: [k-_ how do you know this?
[14:39:45] dgarstang: [k-_: Because it doesn't specifically say it anywhere
[14:40:35] dgarstang: The docs says I can either use Aws.config.update , or I can pass them to Aws::EC2::Resource.new(). In the case of passing to Aws::EC2::Resource.new(), it does not say how credentials was defined
[14:41:34] dgarstang: I'll give it a try. I have no idea how your supposed to connect these two dots. If someone could point out exactly where it says this, it might be useful.
[14:41:45] dgarstang: Like, as in, some text to search
[14:42:54] dgarstang: apeiros: Isn't that text related to Aws.config.update above only?
[14:43:14] dgarstang: "You may also pass configuration options" implies, ok... next option... something different
[14:43:16] dgarstang: Anyway, thanks
[14:44:09] dgarstang: hey hang on.... how am I supposed to set credentials tho. This still doesn't make any sense. If I don't use Aws.config.update()...,. then credentials = what?
[14:45:08] dgarstang: jhass: i don't even know how to set the object
[14:45:15] dgarstang: jhass: i'm not a ruby programmer
[14:45:28] dgarstang: jhass: how do you know this?
[14:45:37] dgarstang: jhass: i've spent the last hour mucking with it
[14:46:31] dgarstang: jhass: Ruby might as well be greek to me. I don't take to it naturally so every inch of ruby is like walking a mile
[14:46:55] dgarstang: but, that page as far as I can see, doesn't set credentials anywhere
[14:47:47] dgarstang: I suppose I could read between the lines and extract credentials: Aws::Credentials.new('akid', 'secret') from Aws.config.update() and do creds = Aws::Credentials.new('akid', 'secret') ?
[14:48:28] dgarstang: jhass: I've been in the biz for 16 years and I am quite capable with python and other languages. ruby is perl all over again and it's ... well not fun
[14:48:52] dgarstang: jhass: I had not tried that variant yet because reading between the lines normally isn't what you first do
[14:49:46] dgarstang: jhass: very
[14:51:00] dgarstang: jeez who'd want to be a programmer all day
[14:54:02] dgarstang: Examples of the aws sdk are hard to come by
[14:54:56] dgarstang: jhass: let me rephrase. if someone has some links to some web pages with useful examples, that would be very much appreciated
[14:55:27] dgarstang: jhass: Thanks!!!! However, API docs are not examples
[14:58:09] dgarstang: jhass: That doesn't assist. Thanks for your help. However, I'll have to keep googling because that page you referred me to does not seem to have any information about how to list and filter instances
[14:59:01] dgarstang: jhass: How can I try what I don't know?
[15:04:03] dgarstang: So now, I'm getting this... https://gist.github.com/dgarstang/74ca0c12fe25262db851
[15:10:19] dgarstang: ljarvis: Thanks. No idea how you arrived at that from the docs
[15:13:23] dgarstang: [k-_: I don't see anything about it saying you had to create credentials first, then a client from that, and finally a resource from that. In any case, I'm still getting the sme result with ljarvis's example https://gist.github.com/dgarstang/5c84af0bf7e90c8ac39c
[15:16:59] dgarstang: ljarvis: No go... https://gist.github.com/dgarstang/5c84af0bf7e90c8ac39c
[15:19:08] dgarstang: ljarvis: not yet
[15:20:33] dgarstang: ljarvis: if I do that, I wont have a client object...
[15:21:25] dgarstang: ljarvis: ok, that worked. Do we have a doc bug then?
[15:22:21] dgarstang: ljarvis: Thanks for your help
[15:22:46] dgarstang: It seems I'm not the only one who has issue with the aws sdk docs
[15:24:14] dgarstang: That's pretty much what I tried with ec2
[15:24:21] dgarstang: sure, I'll try again
[15:25:34] dgarstang: gregf_: this will be a chef helper, so env isn't an option
[15:27:05] dgarstang: gregf_: your earlier pastie works. Well I dont bloody know now.
[15:27:26] dgarstang: gregf_: yours is more succinct, so I'll start with that.
[15:30:15] dgarstang: ljarvis: yep
[16:56:29] dgarstang: What's the ruby way to pass an optional hash to a function and check it's existence in the function?
[16:57:14] dgarstang: shevy: foo = {} or foo = nil ?
[16:57:41] dgarstang: shevy: lets say it was never defined in the first place
[16:58:07] dgarstang: but if it does exist, it will be a hash
[16:59:00] dgarstang: shevy: if condition, set hash. func(hash)
[16:59:19] dgarstang: hash may or may not be defined. ugh, that makes no sense
[16:59:49] dgarstang: one day companies will realise open plan offices make for stupid employees
[17:01:12] dgarstang: let me try this... can I have optional argumements in ruby?
[17:01:28] dgarstang: so I can do foo(arg) or also foo() ?
[17:05:51] dgarstang: Ping timeout: 245 seconds


[15:20:57] dgarstang: has joined #ruby
[15:21:09] dgarstang: How can I extract a portion of text from a multiline string in ruby?
[15:22:32] dgarstang: ljarvis: Let's call it a single line then... :)
[15:23:03] dgarstang: ljarvis: actually I think I can do it line by line
[15:28:00] dgarstang: python has re.match and grouping, so I can do stuff like re.match('foo=(.*?)$',str) and extract everything after the = with re.group(1)... has ruby got an equiv?
[17:58:08] dgarstang: Ping timeout: 252 seconds
[18:24:59] dgarstang: has joined #ruby
[18:27:21] dgarstang: Client Quit


[02:18:08] dgarstang: has joined #ruby
[03:51:47] dgarstang: Ping timeout: 265 seconds
[04:07:26] dgarstang: has joined #ruby
[05:11:40] dgarstang: Quit: WeeChat 0.4.3


[15:59:42] dgarstang: ruby... i dont understand you at all. one error message apparently means something else in ruby
[15:59:50] dgarstang: it's gonna be an uphill battle
[16:01:44] dgarstang: https://github.com/aws/aws-sdk-ruby/issues/635 ... "If you are using the resource interface, you can use the #filter method:" ... yet now I get " `method_missing': undefined method `filter' fo"
[16:02:20] dgarstang: bootstrappm: v2
[16:02:41] dgarstang: boto ain't this hard. :-\
[16:03:20] dgarstang: cbootstrappm: sorry, how?
[16:03:27] dgarstang: bootstrappm: so you think it IS a credentials issue?
[16:04:40] dgarstang: if I could just find a complete example of listing ec2 instances with ruby, it would help, but I'm yet to find that still.
[16:05:03] dgarstang: bootstrappm: then why can't the stack trace tell me that?
[16:06:12] dgarstang: I did this... bootstrappm ec2 = Aws::EC2::Resource.new(region:'us-east-1', credentials: creds) which is what one set of docs said to do
[16:06:25] dgarstang: ljarvis: ok, i'll try that
[16:07:28] dgarstang: Is it ec2 = AWS::EC2.new(access_key_id: "...", secret_access_key: "...") or ... ec2 = AWS::EC2.Resource.new(access_key_id: "...", secret_access_key: "...") ?
[16:08:42] dgarstang: require 'aws-sdk' ; ec2 = AWS::EC2.new(access_key_id: "..", secret_access_key: "..") gets me "./scan.rb:8:in `<main>': uninitialized constant AWS (NameError)"
[16:19:30] dgarstang: screw it. I just put the creds into environment variables
[16:20:52] dgarstang: ok, now we have no consistency on what the filters look like. This page http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Resource.html#instances-instance_method says it's a hash, and this page https://github.com/aws/aws-sdk-ruby/issues/635 says to use a method and pass.. strings?
[16:22:20] dgarstang: but, of course I can't even get the filter() method to work
[16:24:56] dgarstang: Theres no mention whatsoever of filter at http://docs.aws.amazon.com/sdkforruby/api/index.html
[16:26:00] dgarstang: bootstrappm: k, cuz it says the filters method doesn't exist
[16:27:19] dgarstang: bootstrappm: ec2 = Aws::EC2::Resource.new(region:'us-east-1') ; ec2.instances.filter("tag:role", "web").each { |instance| puts instance } == "undefined method `filter'".
[16:29:31] dgarstang: and ... if I replace Resource with Client ... "undefined method `instances' " Sigh
[16:31:11] dgarstang: ec2 = Aws::EC2::Resource.new(region:'us-east-1') ; filters = [{ name: "String", values: ["String"] }] ; ec2.instances(filters: filters).each {|instance| puts instance } == "`call': The filter 'String' is invalid" ... that filter string is straight from http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Resource.html#instances-instance_method
[16:31:39] dgarstang: boto ain't this hard.
[16:31:42] dgarstang: just sayin'
[16:32:57] dgarstang: bootstrappm: boto is the python aws api. i see... so their example don't work. ok, thanks
[18:21:57] dgarstang: Ping timeout: 276 seconds
[18:22:33] dgarstang: has joined #ruby
[18:49:32] dgarstang: how on earth do I use the filters with the aws ruby sdk? filters = [{ name: "tag-key", values: ["enironment"] }] ?
[18:51:41] dgarstang: everything in ruby is so hard, not the least of which there are so few code examples available
[18:53:00] dgarstang: i mean... there's just NO examples
[18:53:28] dgarstang: I'd get more matches on google for 'toothpaste aliens' than "tag-key" "tag-value" aws ruby
[18:53:50] dgarstang: i woudn't have to use it all if I wasn't forced to by ohai
[22:08:03] dgarstang: Ping timeout: 250 seconds