I am trying to add a multi-line comment using the following code but this fails with error shown below, any guidance on how to fix it?
message = """PLEASE RESOLVE MERGE CONFLICTS
WHAT DO I HAVE TO DO IN CASE OF MERGE CONFLICTS:
htts://confluence.sd.company.com/display/WFI/AUTO+CHERRY-PICK
""".replace("\n","\n\n")
code_review_minus_two_cmd = "ssh -p 29418 tech-gerrit.sd.company.com gerrit review %s --label Code-Review=-2 --message '%s'"%(propagated_gerrit_commit,message)
code_review_minus_two_cmd_output,code_review_minus_two_cmd_error = runCmd(code_review_minus_two_cmd)
ERROR:-
fatal: "RESOLVE" is not a valid patch set
Seems related to this bug.
The ways I can see to resolve it from looking through the ticket are:
Use -m instead of --message
Add double quotes around the message
Sample from the review in the bug link:
ssh -p 29418 review.example.com gerrit review -m '"Build Successful"'
Hope something here works. I don't have a gerrit account to test out against myself.
You could use a json formatted message. The easiest way would be to create a file with the following content:
{
"labels": {
"Code-Review": "-2"
},
"message": "PLEASE RESOLVE MERGE CONFLICTS\nWHAT DO I HAVE TO DO IN CASE OF MERGE CONFLICTS:\nhttps://confluence.sd.company.com/display/WFI/AUTO+CHERRY-PICK"
}
Then run this ssh command:
cat filename.json | ssh -p 29418 review.example.com gerrit review --json
It seems the double quotes (""") in the "message" definition aren't working as expected. Gerrit is receiving the parameter like this: --message PLEASE RESOLVE MERGE... so it's assuming that "PLEASE" is the message and "RESOLVE" is the next parameter (patchset) as defined in the gerrit review page at the Gerrit documentation.
Try to use backslashes to escape the double quotes, like this:
message = "\"PLEASE RESOLVE MERGE...\""
The following example works in bash.
ssh -p 29418 review.example.com gerrit review -m $'"First line\nSecond line etc."' CHANGE_ID,PATCHSET_ID/COMMIT_SHA
Related
I am stuck at a problem
What I want to do is once a certain threshold is reached I want to trigger a ticket on KibanaHud from my python code.
I am creating a json file with all the data that I need for the ticket -> ticket.json
I am also using curl Xpost to create index
curl -XPUT 'http://localhost:9200/ticket_tweet/' -d '
index:
number_of_shards: 5
number_of_replicas: 2
'
and then doing
curl -XPOST http://localhost:9200/ticket_tweet/rook_ticket -d #ticket.json
but getting error :
{"error":"UnavailableShardsException[[ticket_tweet][3] Not enough
active copies to meet write consistency of [QUORUM] (have 1, needed
2). Timeout: [1m], request: index
{[ticket_tweet][rook_ticket][AU2zD8QRdqkd3i74WG-f]
the error was of shards....i did some hit and try for the value of shards (since mapping was not available) and the problem got solved. if anyone has a better solution please provide
I have these lines (among other things) in my Django base settings file:
import os
STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "your publishable test key")
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "your secret test key")
I created those two environment variables in my virtualenv like this:
export STRIPE_SECRET_KEY="sk_test_example"
export STRIPE_PUBLIC_KEY="pk_test_example"
When I run env | grep STRIPE, I get this:
STRIPE_SECRET_KEY=sk_test_example
STRIPE_PUBLIC_KEY=pk_test_example
But for some reason, I keep getting this Stripe error: ""Invalid API Key provided: \"\u003C**** ****** **** key\u003E\". This key contains at least one space. Please delete the spaces and try again."
I tried exporting the environment variables again, once without quotation marks and once with single quotation marks, and I got the same result, so I tried printing the STRIPE_SECRET_KEY and STRIPE_PUBLIC_KEY from the settings file, and it returned the defaults, "your publishable test key" and "your secret test key". So that's why there were spaces. But why weren't the environment variables getting picked up?
So I tried getting rid of the defaults in my base settings so the variables look like this:
STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY")
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY")
That threw a NoneType error. I also tried the following:
STRIPE_PUBLIC_KEY = os.environ['STRIPE_PUBLIC_KEY']
STRIPE_SECRET_KEY = os.environ['STRIPE_SECRET_KEY']
That threw "KeyError: u'STRIPE_PUBLIC_KEY'". What do I need to change? I really don't want to hard-code these API keys.
It turns out that I'd forgotten (argh) to export the environment variables in my virtualenv postactivate file and was running the server in a different window, so once I put the Stripe API keys in the postactivate file, I needed to deactivate and activate the virtualenv before running the server.
For API keys, the quotes aren't necessary
export STRIPE_SECRET_KEY=sk_test_example
export STRIPE_PUBLIC_KEY=pk_test_example
It looks like the string format constructed with bash quotes is different than what Python is accepting. I don't know what formats these are, but this would definitely make sense.
Alternatively, you might want to look into a "dotenv" implementation such as django-dotenv.
This is a much more reliable way to work with strings like this. The problem is that when you're using different string formats (UTF-8 vs UTF-16 or Unicode), you may run into the situation where some program is expecting one format but receives another. The output you included is an example of what this looks like (hence my concern here).
Hope this helps!
How do I specify multi-argument matches with python-iptables?
For example, the following iptables command:
-A INPUT -s 1.1.1.1 -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j DROP
If I create the following:
import iptc
rule = iptc.Rule()
rule.src = '1.1.1.1'
rule.protocol = 'tcp'
t = rule.create_target('DROP')
m = rule.create_match('tcp')
m.tcp_flags = 'FIN,SYN,RST,ACK SYN'
it will complain:
ValueError: invalid value FIN,SYN,RST,ACK SYN
PS: I know that for my particular example, I can simply use m.syn = '1', but I'm trying to generalize on how to specify multi-argument matches.
Are you using the latest version? See this issue.
Okay... someone tried to post an answer, but he/she deleted it when I was commenting on it.
The answer attempt was:
m.tcp_flags = ['FIN', 'SYN', 'RST', 'ACK SYN']
which gave the wrong result:
print m.parameters
{u'tcp_flags': u'FIN SYN'}
However, that inspired me to try the following:
m.tcp_flags = ['FIN,SYN,RST,ACK', 'SYN']
which gives:
>>> match.parameters
{u'tcp_flags': u'FIN,SYN,RST,ACK SYN'}
Committing that rule into the INPUT chain and running iptables-save shows that it properly returns the rule I want.
So, thank you!
I'm trying to execute the following code with dumbo(Python) / haddop
https://github.com/klbostee/dumbo/wiki/Short-tutorial#jobs-and-runners
I followed the tutorial correctly, I have done every step but when I run code in hadoop environment I obtain as output as follows:
SEQ/org.apache.hadoop.typedbytes.TypedBytesWritable/org.apache.hadoop.typedbytes.TypedBytesWritable�������ޭǡ�q���%�O��������������172.16.1.10������������������172.16.1.12������������������172.16.1.30������
It should return a list of IP addresses with connections counter.
Why those characters appear? Is it an encoding problem? How do I fix it? Thanks
Also if I try other programs in the tutorial, I have the same problem.
I answer by myself. That output is the serialized form of Dumbo. There is no error.
To convert it into a readable text, it's sufficient the follow command (the answer was in the tutorial ! I don't saw it)
dumbo cat ipcounts/part* -hadoop /usr/local/hadoop | sort -k2,2nr | head -n 5
I'm using openldap on Mac OS X Server 10.6 and need to generate a vcard for all the users in a given group. By using the ldapsearch I can list all the memberUid's for all users in that group. I found a perl script (Advanced LDAP Search or ALS) that was written by someone that will generate the vcard easily. ALS can be found here http://www.ldapman.org/tools/als.gz
So what I need to do is create a wrapper script (in python or perl) that will effectively loop through the memberUid's and run the ALS command to create the vcard and append it to the file.
This command provides the memberUid's:
ldapsearch -x -b 'dc=ldap,dc=server,dc=com' '(cn=testgroup)'
Then running ALS gives the vcard:
als -b dc=ldap,dc=server,dc=com -V uid=aaronh > vcardlist.vcf
If it's easier to do this using Perl since ALS is already using it that would be fine. I've done more work in python but I'm open to suggestions.
Thanks in advance,
Aaron
EDIT:
Here is a link to the Net:LDAP code that I have to date. So far it pulls down the ldap entries with all user information. What I'm missing is how to capture just the UID for each user and then push it into ALS.
http://www.queencitytech.com/net-ldap
Here is an example entry (after running the code from the above link):
#-------------------------------
DN: uid=aaronh,cn=users,dc=ldap,dc=server,dc=com
altSecurityIdentities : Kerberos:aaronh#LDAP.SERVER.COM
apple-generateduid : F0F9DA73-70B3-47EB-BD25-FE4139E16942
apple-imhandle : Jabber:aaronh#ichat.server.com
apple-mcxflags : <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>simultaneous_login_enabled</key>
<true/>
</dict>
</plist>
authAuthority : ;ApplePasswordServer;0x4c11231147c72b59000001f800001663,1024 35 131057002239213764263627099108547501925287731311742942286788930775556419648865483768960345576253082450228562208107642206135992876630494830143899597135936566841409094870100055573569425410665510365545238751677692308677943427807426637133913499488233527734757673201849965347880843479632671824597968768822920700439 root#ldap.server.com:192.168.1.175;Kerberosv5;0x4c11231147c72b59000001f800001663;aaronh#LDAP.SERVER.COM;LDAP.SERVER.COM;1024 35 131057002239213764263627099108547501925287731311742942286788930775556419648865483768960345576253082450228562208107642206135992876630494830143899597135936566841409094870100055573569425410665510365545238751677692308677943427807426637133913499488233527734757673201849965347880843479632671824597968768822920700439 root#ldap.server.com:192.168.1.170
cn : Aaron Hoffman
gidNumber : 20
givenName : Aaron
homeDirectory : 99
loginShell : /bin/bash
objectClass : inetOrgPersonposixAccountshadowAccountapple-userextensibleObjectorganizationalPersontopperson
sn : Hoffman
uid : aaronh
uidNumber : 2643
userPassword : ********
#-------------------------------
My language of choice would be Perl - but only because I've done similar operations using Perl and LDAP.
If I remember correctly, that ldapsearch command will give you the full LDIF entry for each uid in the testgroup cn. If that's the case, then you'll need to clean it up a bit before it's ready for the als part. Though it's definitely not the most elegant solution, a quick and dirty method is to use backticks and run the command's output through a grep. This will return a nice list of all the memberUids. From there it's just a simple foreach loop and you're done. Without any testing or knowing for sure what your LDAP output looks like, I'd go with something like this:
#!/usr/bin/perl
# should return a list of "memberUid: name" entries
#uids = `ldapsearch -x -b 'cn=testgroup,cn=groups,dc=ldap,dc=server,dc=com' | grep memberUid:`;
foreach (#uids) {
$_ =~ s/memberUid: //; # get rid of the "uid: " part, leaving just the name
chomp $_; # get rid of the pesky newline
system "als -b \"dc=ldap,dc=server,dc=com\" -V uid=$_ >> vcardlist.vcf";
}
As I said, I haven't tested this, and I'm not exactly sure what the output of your ldapsearch looks like, so you may have to tweak it a bit to fit your exact needs. That should be enough to get you going though.
If anyone has a better idea I'd love to hear it too.