I'm trying to download a file from an opa database. I've used the following code :
case {path:[], query:[("download", filename)], ...} : Resource.binary(/myDatabase[filename], "application/txt")
It's working fine, but the file I download is always named "download.txt". How can I change this name ?
Thanks
case {path:[], query:[("download", filename)], ...} : Resource.binary(/myDatabase[filename], "application/txt") |> Resource.add_header(_, {content_disposition={attachment=filename}})
Related
came across a similar question here which wasn't truly addressed - https://github.com/nightwatchjs/nightwatch/issues/1911
You cannot do what #beatfactor suggested with the above example, the port is in the middle i.e. "selenium_host" : "us1.appium.testobject.com:443/wd/hub",
I'm facing a similar problem right now, how do I provide arguments so it attempts to hit a host like the above? Currently, my failing options are providing no port which defaults to 4444 or providing a port which results in attempting to hit us1.appium.testobject.com/wd/hub:443
The desired result is :
"selenium_host" : "us1.appium.testobject.com:443/wd/hub",
TLDR - How do you provide a port in the middle of your selenium host argument given the port is always appended to the end and if you don't provide one, a default is used?
Just define your selenium_port upstream, in the declaration section and use a Template Literal:
const selenium_port = '443';
"test_settings" : {
"default" : {
"launch_url" : "http://test.com",
"selenium_port" : selenium_port
"selenium_host" : `us1.appium.testobject.com:${selenium_port}/wd/hub`,
"silent" : true,
"screenshots" : {
"enabled" : true,
"path" : "screenshots"
}
},
Hope I understood correctly. Cheers!
this work :
mybot.sendDocument(chat_id=chatid, document=open('bla.pdf', rb'))
But if I did before :
with open('bla.pdf', 'rb') as fp:
b = fp.read()
I can't do :
mybot.sendDocument(chat_id=chatid, document=b)
The error is :
TypeError: Object of type 'bytes' is not JSON serializable
I use python 3.5.2 win or linux
Thanks for answer
sorry I didn't see your answer.
My trouble was I wanted to send a downloaded document, not a document on disk.
I resolved it like this :
mybot.sendDocument(chat_id=chatid,document=io.BytesIO(self.downloaded_file))
Try to send just a file object:
mybot.sendDocument(chat_id=chatid, document=open('bla.pdf', 'rb'))
I've got a simple DataPipeline job which has only a single an EmrActivity with a single step attempting to execute a hive script from my s3 bucket.
The config for the EmrActivity looks like this:
{
"name" : "Extract and Transform",
"id" : "HiveActivity",
"type" : "EmrActivity",
"runsOn" : { "ref" : "EmrCluster" },
"step" : ["command-runner.jar,/usr/share/aws/emr/scripts/hive-script --run-hive-script --args -f s3://[bucket-name-removed]/s1-tracer-hql.q -d INPUT=s3://[bucket-name-removed] -d OUTPUT=s3://[bucket-name-removed]"],
"runsOn" : { "ref": "EmrCluster" }
}
And the config for the corresponding EmrCluster resource it's running on:
{
"id" : "EmrCluster",
"type" : "EmrCluster",
"name" : "Hive Cluster",
"keyPair" : "[removed]",
"masterInstanceType" : "m3.xlarge",
"coreInstanceType" : "m3.xlarge",
"coreInstanceCount" : "2",
"coreInstanceBidPrice": "0.10",
"releaseLabel": "emr-4.1.0",
"applications": ["hive"],
"enableDebugging" : "true",
"terminateAfter": "45 Minutes"
}
The error message I'm getting is always the following:
java.io.IOException: Cannot run program "/usr/share/aws/emr/scripts/hive-script --run-hive-script --args -f s3://[bucket-name-removed]/s1-tracer-hql.q -d INPUT=s3://[bucket-name-removed] -d OUTPUT=s3://[bucket-name-removed]" (in directory "."): error=2, No such file or directory
at com.amazonaws.emr.command.runner.ProcessRunner.exec(ProcessRunner.java:139)
at com.amazonaws.emr.command.runner.CommandRunner.main(CommandRunner.java:13)
...
The main error msg being "... (in directory "."): error=2, No such file or directory".
I've logged into the master node and verified the existence of /usr/share/aws/emr/scripts/hive-script. I've also tried specifying an s3-based location for the hive-script, among a few other places; always the same error result.
I can manually create a cluster directly in EMR that looks exactly like what I'm specifying in this DataPipeline, with a Step that uses the identical "command-runner.jar,/usr/share/aws/emr/scripts/hive-script ..." command string, and it works without error.
Has anyone experienced this, and can advise me on what I'm missing and/or doing wrong? I've been at this one for awhile now.
I'm able to answer my own q, after some long research and try-error.
There were 3 things, maybe 4, wrong with my Step script:
needed the 'script-runner.jar', rather than the 'command-runner.jar', as we're running a script (which I ended up just pulling from EMR's libs dir on s3)
need to get the 'hive-script' from elsewhere - so, also went to the public EMR libs dir in s3 for this
a fun one, yay thanks AWS; for the Steps args (everything after the 'hive-script' specification)...need to comma-separate every value in it when in DataPipeline (as opposed to space-separating as you do when specifying args in a Step directly in EMR)
And then the "maybe 4th":
included the base folder in s3 and specific hive release we're working with for the hive-script (I added this as result of seeing something similar in an AWS blog, but haven't yet tested whether it makes a difference in my case, too drained with everything else)
So, in the end, my working EmrActivity ended looking like so:
{
"name" : "Extract and Transform",
"id" : "HiveActivity",
"type" : "EmrActivity",
"runsOn" : { "ref" : "EmrCluster" },
"step" : ["s3://us-east-1.elasticmapreduce/libs/script-runner/script-runner.jar,s3://us-east-1.elasticmapreduce/libs/hive/hive-script,--base-path,s3://us-east-1.elasticmapreduce/libs/hive/,--hive-versions,latest,--run-hive-script,--args,-f,s3://[bucket-name-removed]/s1-tracer-hql.q,-d,INPUT=s3://[bucket-name-removed],-d,OUTPUT=s3://[bucket-name-removed],-d,LIBS=s3://[bucket-name-removed]"],
"runsOn" : { "ref": "EmrCluster" }
}
Hope this helps save someone else from the same time-sink I invested. Happy coding!
In my project, i want to add data :
"\n<p>sadasdasdsad</p>"
i use :
CSParameterCollection parameters = new CSParameterCollection();
parameters.Add("#title", f.Title.ToString());
parameters.Add("#sumary", f.Summary.ToString());
parameters.Add("#link[",f.Links[0].Uri.ToString());
parameters.Add("#datetime", f.PublishDate.ToString());
parameters.Add("#cid", idCate.ToString());
CSDatabase.ExecuteNonQuery("INSERT INTO Acticle (title,sumary,link,datetime,cid) VALUES ('#title','#sumary','#link','#datetime','#cid')",parameters);
but nerver complete .
Please help me !
A quick look at that, you have
parameters.Add("#link[",f.Links[0].Uri.ToString());
Do you need that [ in there, after #link, or is it a typo?
I don't know how to accomplish this in general, but I'll ask about one instance in particular for clarity:
Sexplib looks interesting to me. I want to play around with it. I've downloaded it, installed it just fine (I'm pretty sure, anyway), etc. I want to use the "with sexp" syntax extension in a toplevel. How would I go about doing this? All the examples I've found of its use assume you already know how to make the toplevel and/or compile with the syntax extensions.
My best shot at it was something like this:
ocamlmktop -I +site-lib/sexplib -pp "camlp4 -I +site-lib/sexplib pa_sexp_conv.cma" -o sexplib-top
When I run this toplevel, I can open Sexplib just fine, but when I try using the with sexp syntax extension, I get a syntax error.
It is XXI century already - use ocamlfind :
Objective Caml version 3.11.2
# #use "topfind";;
- : unit = ()
# #camlp4o;;
/usr/lib/ocaml/dynlink.cma: loaded
/usr/lib/ocaml/camlp4: added to search path
/usr/lib/ocaml/camlp4/camlp4o.cma: loaded
Camlp4 Parsing version 3.11.2
# #require "sexplib.syntax";;
/usr/lib/ocaml/unix.cma: loaded
/usr/lib/ocaml/bigarray.cma: loaded
/usr/lib/ocaml/nums.cma: loaded
/usr/lib/ocaml/num-top: added to search path
/usr/lib/ocaml/num-top/num_top.cma: loaded
/usr/lib/ocaml/sexplib: added to search path
/usr/lib/ocaml/sexplib/sexplib.cma: loaded
/usr/lib/ocaml/type-conv: added to search path
/usr/lib/ocaml/type-conv/pa_type_conv.cmo: loaded
/usr/lib/ocaml/sexplib/pa_sexp_conv.cmo: loaded
# type t = { x : int; y : float; } with sexp;;
type t = { x : int; y : float; }
val t_of_sexp__ : Sexplib.Sexp.t -> t = <fun>
val t_of_sexp : Sexplib.Sexp.t -> t = <fun>
val sexp_of_t : t -> Sexplib.Sexp.t = <fun>