I am newbie to Ruby, want to understand the syntax for client.wait_until.
I have a lambda client which needs to wait for function update to apply the next set of function updates. I want to use wait_until here. I have read through https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/Lambda/Client.html#get_function_configuration-instance_method here but still not able to figure out how this works.
Below is code sample :
function_config = create_or_update_lambda(lambda_config, #deployer_config.runtime)
##I have to wait till the above update finishes.
lambda_client = get_lambda_client(lambda_config)
lambda_client.wait_until(:function_updated,lambda_client.get_function_configuration({function_name: lambda_config.function}))
update_function_code(s3_object_version, lambda_config)
I figured out the correct way of calling wait_until is like this :
lambda_client.wait_until(:function_updated,
function_name: function_trying_to_update_lambda[:function_name])
where function_trying_to_update_lambda is trying to update my lambda and is followed by another lambda update function.
Related
I am working through the ruby evernote-thrift API and sandbox.
I am experiencing some issues interpreting the docs; I am trying to retrieve the subject line from all the notes inside a particular notebook.
To get the name of the notebook I call
notebooks = noteStore.listNotebooks(authToken) and then run .each on notebooks. According to the docs there is a struct object called noteList but I can’t figure out how to use it.
this is the link to the docs area I am trying to leverage http://www.rubydoc.info/gems/evernote-thrift/Evernote/EDAM/NoteStore/NoteList#struct_fields-instance_method
my attempt, is as follows, but its not returning anything. unfortunately im not familiar with structs at all.
notebooks = noteStore.listNotebooks(authToken)
notebooks.each do |notebook|
next if notebook.name != 'First Notebook'
notes = notebook.noteList
noteList.each do |note|
puts note
end
end
i am getting a no method error... which makese sense because its a struct I just dont know how to leverage it...
undefined method `noteList' for <Evernote::EDAM::Type::Notebook:0x007fb2041683f8> (NoMethodError)
The generated docs for our Ruby SDK are confusing (sorry!), but I find the general docs to be much clearer: https://dev.evernote.com/doc/reference/.
As you can see in https://dev.evernote.com/doc/reference/Types.html#Struct_Notebook, the Notebook object does not have an attribute called noteList. There is a struct called NoteList, but that was what the removed NoteStore.findNotes returned.
The procedure for getting the titles/subjects of the notes in a notebook is to get the Notebook (which you have done), then pass the notebook's guid into NoteStore.findNotesMetadata (https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_findNotesMetadata). This returns a NotesMetadataList which has a notes attribute which is a list of NoteMetadata. This struct has metadata like title and GUID but not the body. If you want the full information, you would pass the GUID into NoteStore.getNote (https://dev.evernote.com/doc/reference/NoteStore.html#Fn_NoteStore_getNote).
That API is one of the least Ruby things I've ever seen. You have my condolences for trying to trudge through that :)
From the API docs, all I'm seeing that hangs off of that Evernote::EDAM::Type::Notebook class are #struct_fields and #validate, as far as instance methods go. Perhaps that struct_fields has what you're looking for?
If that doesn't lead you anywhere, I'd suggest doing using something like Pry to help you troubleshoot the error. I'd put a binding.pry statement on the second line and then explore the notebooks objects from there.
I have a test that works right now but it's ugly and I can't help thinking there is a better way to do this. Basically I pick a record from the database and then make an api call which should affect that record. However the only way to make the test pass is to pull the record from the database a second time.
it "counts how many times a client has pulled its config" do
client = Endpoint.last
config_count = client.config_count
post '/api/config', node_key: client.node_key
same_client = Endpoint.find_by node_key: client.node_key
# expect(client.config_count).to eq(config_count + 1)
expect(same_client.config_count).to eq(config_count + 1)
end
The commented out line does not work. This fix is so ugly that it makes me think I'm doing it wrong. I also tried this:
expect {post '/api/config', node_key: client.node_key}.to change {client.config_count}.by(1)
So what is the proper way to test this?
Probably several ways to solve it. I tend to call .reload on my object if I want updated values for it and don't care what exactly is happening inside the object itself.
it "counts how many times a client has pulled its config" do
client = Endpoint.last
config_count = client.config_count
post '/api/config', node_key: client.node_key
client.reload
expect(client.config_count).to eq(config_count + 1)
end
I'd like to download Windows updates by use of WIN32OLE in Ruby. I'm running into issues knowing which COM object to use in order to get the arguments needed by IUpdateDownloader::BeginDownload . For the time being, I can execute the synchronous version of downloading updates, but I would really like to know how I can go about using the asynchronous method.
Something such as the following works now:
require 'win32ole'
muSession = WIN32OLE.new('Microsoft.Update.Session')
availableUpdates = muSession.CreateUpdateSearcher().Search("IsInstalled=0 and Type='Software'").Updates
muUpdateColl = WIN32OLE.new('Microsoft.Update.UpdateColl')
availableUpdates.each do |update|
update.AcceptEula()
muUpdateColl.Add(update)
end
updateDownloader = WIN32OLE.new('Microsoft.Update.Session').CreateUpdateDownloader()
updateDownloader.Updates = muUpdateColl
downloadResult = updateDownloader.Download()
However, instead of invoking "Download()", I would like to use "BeginDownload()". How can I instantiate IDownloadProgressChangedCallback (for example). I think doing so may be obvious in C#, but using WIN32OLE, I am not sure how to create the object.
It looks like its no longer possible use
scenario.status
in Cucumber 2.0.0 to determine the status of a scenario (passed, failed, undefined, skipped). It looks like it is possible to see if a scenario either passes or fails, but I'm also looking to see when steps are undefined or skipped.
Previously, in my code I would write the results to a DB in the After hook of the scenario, like so:
After do |scenario|
#controller.post_results(scenario)
end
Inside of post results, I would call scenario.status to get the status.
Is this no longer possible to do with Cucumber 2.0.0? If it is, what is the new method?
You need to use Hooks.rb to get the status of scenario.
You can use
if scenario.failed?
todo...
end
or
scenario.status
inside the hooks.rb.
Find more details here: https://github.com/cucumber/cucumber/wiki/Hooks
I'm trying to make an update script for windows7 in vbscript
when invoking IUpdateSearcher::BeginSearch how do I pass the callback to ISearchCompletedCallback::Invoke Method?
I'm just clueless on this points:
do I need an function or sub or does this a custom object with an invoke method(and how to create)
how I need to pass the callback
is it even possible in vbscript (if not what is a good next step?)
Thanks
I've never tried it, but I'd look at the ConnectObject Method.
This article about scripting events might also be useful.
So maybe something like this (complete guess):
Set objSession = CreateObject("Microsoft.Update.Session")
Set objSearcher = objSession.CreateUpdateSearcher
WScript.ConnectObject objSearcher, "searcherCallBack_"
objSearcher.BeginSearch ...
sub searcherCallBack_Invoke()
' handle the callback
end sub
I'd also suggest reading Guidelines for Asynchronous WUA Operations to make sure that you clean up after yourself.
that link also mentions using Windows Script Host, so it should definitely be possible to do this, though unless you need it to be asynchronous, the synchronous methods wouls probably be a easier.