How to keep app from crashing while using the subprocess in Python - python

Greetings to the stackoverflow community. I need some direction in how to keep my Python cmd line app from crashing when the network I'm cloning a repository from (GitHub) disconnects because many clone requests. Below is the code that I use to clone the repo. Currently, it runs fine. But, I imagine, when there are multiple people downloading the repo or something is slow about the network, I get kicked off, and my app crashes. I thought the try/except statement would prevent crashing, but to no avail:
...
command = r'git clone git#github.com:somerepo.git'
try:
subprocess.call(command, shell=False)
except subprocess.CalledProcessError as cpe:
click.echo(cpe.output)
...
Error:
Git Clone Fails - error: RPC failed; result=56, HTTP code = 200
git clone http://somerepo/repo.git
fatal: early EOF
fatal: The remote end hung up unexpectedly
fatal: index-pack failed
error: RPC failed; result=56, HTTP code = 200

Related

Ansible ec2.py runs standalone but fails in playbook

I've seen a few posts on this topic with odd hard to reproduce behaviours. Here's a new set of data points.
Currently the following works
cd ./hosts
./ec2.py --profile=dev
And this fails
AWS_PROFILE=dev; ansible-playbook test.yml
These were both working a couple days ago. Something in my environment changed. Still investigating. Any guesses?
Error message:
ERROR! The file ./hosts/ec2.py is marked as executable, but failed to execute correctly. If this is not supposed to be an executable script, correct this withchmod -x ./hosts/ec2.py.
ERROR! Inventory script (./hosts/ec2.py) had an execution error: ERROR: "Error connecting to AWS backend.
You are not authorized to perform this operation.", while: getting EC2 instances
ERROR! ./hosts/ec2.py:3: Error parsing host definition ''''': No closing quotation
Note that the normal credentials error is:
ERROR: "Error connecting to AWS backend.
You are not authorized to perform this operation.", while: getting EC2 instances
...
Hmmm. Error message has shifted.
AWS_PROFILE=dev; ansible-playbook test.yml
ERROR! ERROR! ./hosts/tmp:2: Expected key=value host variable assignment, got: {
Looks like the problem was a temporary file in the hosts folder. After removing it the problems went away. It looks like std ansible behaviour: Pull in ALL files in the hosts folder.

How do I set up a Jenkins CI server to run automated BDD selenium tests using a remote webdriver?

I'm new to Jenkins and am trying to set up a server to run selenium tests from a GitHub repo. I'm sure that I'm doing something wrong, likely several things, but haven't been able to figure it out.
I have configured the selenium plugin to use the default Selenium hub port 4444.
Project GitHub Configuration
Can't figure out why I'm getting this error. The credentials match the created username and ssh key. I can even access the repo by clicking on GitHub in the project dashboard.
Project Shell Execution Steps
The before-build execution steps. These are the commands I use in the terminal to run the tests locally.
When I build the job it gives the following log:
Started by <user>
Building in workspace /Users/Shared/Jenkins/Home/workspace/Tutorial
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/<repo address>.git # timeout=10
Fetching upstream changes from https://github.com/<repo address>.git
> git --version # timeout=10
using GIT_SSH to set credentials
> git fetch --tags --progress https://github.com/<repo address>.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/<repo address>.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:809)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1076)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1107)
at hudson.scm.SCM.checkout(SCM.java:496)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1281)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1728)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:405)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://github.com/<repo address>.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/<repo address>.git/'
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1877)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1596)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:807)
... 11 more
ERROR: null
Finished: FAILURE
If you are using SSH key for Jenkins to authenticate try using SSH version e.g. git#github.com:FOO/BAR.git instead of HTTPS one.

stratum-mining-proxy error - Can't decode message

I'm attempting to run stratum-mining-proxy with minerd. Proxy starts and runs with the following command:
python ./mining_proxy.py -o ltc-stratum.kattare.com -p 3333 -pa scrypt
Proxy starts fine. Run Minerd (U/P removed):
minerd -a scrypt -r 1 -s 6 -o http://127.0.0.1:3333 -O USERNAME.1:PASSWORD
Following errors are received. This one from the proxy:
2013-07-18 01:33:59,981 ERROR protocol protocol.dataReceived # Processing of message failed
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/stratum-0.2.12-py2.7.egg/stratum/protocol.py", line 185, in dataReceived
self.lineReceived(line, request_counter)
File "/usr/local/lib/python2.7/dist-packages/stratum-0.2.12-py2.7.egg/stratum/protocol.py", line 216, in lineReceived
raise custom_exceptions.ProtocolException("Cannot decode message '%s'" % line)
'rotocolException: Cannot decode message 'POST / HTTP/1.1
And this from minerd. What am I doing wrong? Any help is appreciated!
[2013-07-18 01:33:59] HTTP request failed: Empty reply from server
[2013-07-18 01:33:59] json_rpc_call failed, retry after 30 seconds
I am a little curious, I don't know as a fact but I was under the impression that the mining proxy was for BTC not LTC.
But anyways I believe I got a similar message when I first installed it as well. To fix, or rather to actually get it running I had to use the Git installation method instead of installing manually.
Installation on Linux using Git
This is advanced option for experienced users, but give you the easiest way for updating the proxy.
1.git clone git://github.com/slush0/stratum-mining-proxy.git
2.cd stratum-mining-proxy
3.sudo apt-get install python-dev # Development package of Python are necessary
4.sudo python distribute_setup.py # This will upgrade setuptools package
5.sudo python setup.py develop # This will install required dependencies (namely Twisted and Stratum libraries), but don't install the package into the system.
6.You can start the proxy by typing "./mining_proxy.py" in the terminal window. Using default settings, proxy connects to Slush's pool interface.
7.If you want to connect to another pool or change other proxy settings, type "./mining_proxy.py --help".
8.If you want to update the proxy, type "git pull" in the package directory.

what is this error when deploying google python-appengine application?

this is the error message .. any help will be appreciated .
2011-02-23 23:09:11 Running command: "['C:\\Python25\\pythonw.exe', '-u', 'C:\\Program Files\\Google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=adham587#gmail.com', '--passin', 'update', 'C:\\Users\\adham\\Desktop\\images']"
Application: refacingme; version: 1.
Server: appengine.google.com.
Scanning files on local disk.
Initiating update.
2011-02-23 23:09:42,223 WARNING appengine_rpc.py:405 ssl module not found.
Without the ssl module, the identity of the remote host cannot be verified, and
connections may NOT be secure. To fix this, please install the ssl module from
http://pypi.python.org/pypi/ssl .
To learn more, see http://code.google.com/appengine/kb/general.html#rpcssl .
Password for XXXXX#gmail.com: Error 409: --- begin server output ---
Another transaction by user XXXXXXXX is already in progress for this app and major version. That user can undo the transaction with appcfg.py's "rollback" command.
--- end server output ---
2011-02-23 23:09:46 (Process exited with code 1)
You can close this window now.
This problem can occur if an update is started and does not finish for whatever reason. As the error message notes, the correct thing to do is to give appcfg.py the rollback command. That will undo the failed changes and reset your app so it is ready for an update.
Try
easy_install ssl
The message says that module is missing.
#Adam: duly noted. I apologize for missing the "Warning text".
I believe his error will go away in a while since another operation might be going on at the same time. He should install ssl module nevertheless. If after a while and it doesn't help, he should perform a rollback.
Google App Engine: appcfg.py rollback

hg pull from bitbucket using fabric

I'm trying to use fabric to deploy a Django project and I get this error when I run hg pull:
[myusername.webfactional.com] run: hg pull
[myusername.webfactional.com] out: remote: Warning: Permanently added the RSA host key for IP address '207.223.240.181' to the list of known hosts.
[myusername.webfactional.com] out: remote: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
[myusername.webfactional.com] err: abort: no suitable response from remote hg!
Fatal error: run() encountered an error (return code 255) while executing 'hg pull'
I can run other mercurial commands like hg status, and hg log just fine from my fab file.
I have generated an SSH key on the server and added it to my bitbucket account. This works as I can SSH in and run hg pull and it works fine, it's only when using fabric.
This is my fabfile:
from __future__ import with_statement
from fabric.api import *
env.hosts = ['myusername.webfactional.com']
env.user = "myusername"
def development():
# Update files
local("hg push")
with cd("~/webapps/mysite/mysite"):
run("hg pull")
# Update database
with cd("~/webapps/mysite/mysite"):
run("python2.6 manage.py syncdb")
run("python2.6 manage.py migrate")
# Reload apache
run("~/webapps/mysite/apache2/bin/restart")
Any ideas?
EDIT:
Got this working using https
so instead of
hg pull
I'm using
hg pull https://myusername#bitbucket.org/myusername/mysite
Can't reproduce.
zada$ fab development
[ostars.com] Executing task 'development'
[ostars.com] run: hg pull
[ostars.com] out: pulling from ssh://hg#bitbucket.org/Zada/b
[ostars.com] out: no changes found
Done.
Disconnecting from ostars.com... done.
zada$ hg --version
Mercurial Distributed SCM (version 1.6.3)
zada$ ssh ostars.com "hg --version"
Mercurial Distributed SCM (version 1.6)
zada$ fab --version
Fabric 0.9.2
Possible reasons: versions mismatch. Or just a glitches on Butbucket :)
Try run("hg pull") to be more verbose.
To use SSH to clone or pull or push repository in BitBucket you need to follow this instruction (this document is for Mercurial on Mac OSX or Linux) :
https://confluence.atlassian.com/pages/viewpage.action?pageId=270827678
If you want to setup other ssh to to work with bitbucket, here is the full documentation :
https://confluence.atlassian.com/display/BITBUCKET/How+to+install+a+public+key+on+your+Bitbucket+account

Categories

Resources