Drupal Curl, $GET - post

I am creating a Drupal 7 node from remote. In my server I have a script that uses
now=$(date)
curl --data "date=$now" http://website.com
That is supposed to send the value of $now to the url. In my remote nodecreate.php form I am using
$node->field_date[$node->language][0]['value'] = $_GET['date'];
To set the value of the date field in the node. Problem is that the node is created successfully, but the date is blank.
I have tried other variations such as setting a value to a string in the remote nodecreate.php like this
$date = $_GET['date'];
$node->field_date[$node->language][0]['value'] = $date;
however that did not work either. Anyone got ideas what is wrong here?

You probably should use the following :
$node->field_date[LANGUAGE_NONE][0]['value'] = $date;
I suppose here that you are using translation on node but not translatable fields.

Related

When creating a sqlalchemy.engine.url.URL, how do I add the file where the SSL Certification is kept

I'm using great_expectations==0.13.4 and sqlalchemy==1.3.22 and am attempting to create the string which will provide the connection in URL format. These will be added manually to the systems, as the CLI does not allow for identification of the CERT or the Schema.
I'm using the following code to define and connect to the URL, while I had this working last night my computer rebooted before I could hit save. I believe the issue is with line "query={"ssl_ca": certificate_file}", but I cannot identify the correct keyword to allow the cert file to be listed in the URL.
Any and all help is appreciated. Thank you
import sqlalchemy
certificate_file = r'c:\Users\Dir\To\My\Certificate.crt'
sqlUrl = sqlalchemy.engine.url.URL(
drivername='presto',
username=actual_user,
password= quote_plus(actual_pswd),
host= hostname,
port=port_num,
database=db_name,
query={"ssl_ca": certificate_file}
)
engine = sqlalchemy.create_engine(sqlUrl)
with engine.connect() as connection:
result = connection.execute("show schemas")
The error I get is during the line above ("with engine.connect() as connecton") is
StatementError: (builtins.TypeError) __init__() got an unexpected keyword argument 'ssl_ca'
[SQL: show schemas]
I have tried options in the URL connection for query (request_kwargs, verify & ca, ssl_ca) and some variations there in. So far no luck

Get all logs of the current Jenkins build with currentBuild.rawBuild.getLog

I want all my jenkins logs of my current build in groovy
env.logs = currentBuild.rawBuild.getLog(1000).join('\n')
This works, but the problem here is I have to specify the amount of lines.
When I use:
env.logs = currentBuild.rawBuild.getLog().join('\n')
env.logs is empty. What is the right command to get all the logs without specifying the amount of lines. Is this possible?
currentBuild.rawBuild.log seems to work but is deprecated?
You can use the getLog method with a max value getLog(Integer.MAX_VALUE)
This is working for me - it reads the actual log file instead of using the API:
logFileContent = new File("${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/log").collect {it}

py2neo Error returning data from Cypher query

My simple code is retrieving attributes from nodes in neo4j.
results = graph.cypher.execute("MATCH (m)-[:AB]->(a) "
"RETURN m.searchField as origin, a.searchField as destination "
"LIMIT {limit}", {"limit": 100})
nodes = []
rels = []
i = 0
for r in results:
print (r)
ent1 = {"title": r.origin, "label": "entity"}
but the server returns "NameError("global name 'searchField' is not defined",)" Certainly I missed something, but I'm puzzled that the searchField inside the Cypher query is the object of the error.
This is still with py2neo 2.0.8.
Thanks for any pointer, hj
Later editing:
Thanks for taking the time to look at this question. Two elements further puzzle me in this error:
1. The query in cypher is fine, and returns the result I expect in neo4j-shell without problem
2. This code seems to work fine when I run bottle as standalone (run(port=8080) in main), but fails when I run it as wsgi under an apache server. I am wondering if it is a problem of running user, or of context in some part of the code.
Do you have a property called searchField on the node(s)?
If not, the query will fail.
BTW, it is easier to use a string for the query like so:
query = '''
MATCH (m)-[:AB]->(a)
RETURN m.searchField as origin, a.searchField as destination
LIMIT {limit}
'''
result = graph.cypher.execute(query, limit='foo')
Got it to work! It was unrelated to code, but I did not know that any refresh of a new python code served through wsgi requires an apache reload at least.
sudo service apache2 reload
With that I obtain the same (and correct) behavior as with the direct server. The error was the result of an old version of the code... newbie mistake!
Thanks and sorry for the hassle, hj

Why doesn't the default attribute for number fields work for Jenkins jelly configurations?

I'm working on a Jenkins plugin where we make a call out to a remote service using Spring's RestTemplate. To configure the timeout values, I'm setting up some fields in the global configuration using the global.jelly file for Jenkins plugins using a number field as shown here:
<f:entry title="Read Timeout" field="readTimeout" description="Read timeout in ms.">
<f:number default="3000"/>
</f:entry>
Now, this works to save the values and retrieve the values no problem, so it looks like everything is setup correctly for my BuildStepDescriptor. However, when I first install the update to a Jenkins instance, instead of getting 3000 in the field by default as I would expect, instead I am getting 0. This is the same for all the fields that I'm using.
Given that the Jelly tag reference library says this attribute should be the default value, why do I keep seeing 0 when I first install the plugin?
Is there some more Java code that needs to be added to my plugin to tie the default in Jelly back to the global configuration?
I would think that when Jenkins starts, it goes to get the plugin configuration XML and fails to find a value and sets it to a default of 0.
I have got round this in the past by setting a default in the descriptor (in groovy) then this value will be saved into the global config the first time in and also be available if the user never visits the config page.
#Extension
static class DescriptorImpl extends AxisDescriptor {
final String displayName = 'Selenium Capability Axis'
String server = 'http://localhost:4444'
Boolean sauceLabs = false
String sauceLabsName
Secret sauceLabsPwd
String sauceLabsAPIURL =
'http://saucelabs.com/rest/v1/info/platforms/webdriver'
String sauceLabsURL = 'http://ondemand.saucelabs.com:80'
from here

Executing build with parameters from Java program

I am trying to execute a Jenkins build from my Java program using the Resty framework (using Resty isn't a requirement, just seemed like the easiest way). It works fine for jobs without parameters, including authentication, however I am trying to execute a build with a parameter but I am getting the (non-descript) Error 500 returned from Jenkins server.
URI jenkinsURI = new URI("https://"+jenkinsServer+"/job/bowling%20Q%20build/build?token="+jenkinsToken);
String b = URLEncoder.encode("json={\"parameter\": [{\"name\": \"git_tag\", \"value\": \"v1\"}],\"\":\"\"", "UTF-8");
System.out.println("My Results: "+r.text(jenkinsURI, Resty.content(b)));
Any idea how to do this? I have followed these instructions for sending the JSON and it works fine from curl, but does not from Java Resty.
The problem was that I didn't/can't use the URLEncoder. Once I changed the Resty.content to
System.out.println("My Results: "+r.text(jenkinsURI, Resty.form(Resty.data("json", "{\"parameter\": [{\"name\": \"git_tag\", \"value\": \"1.0.4\"}],\"\":\"\"}"))));
it started working fine.

Resources