Monday, December 23, 2013

Matlab keyboard equivalent in python

I use the keyboard command all of the time in Matlab to get a live shell during an 
exception, etc.. so this is how you do it in python
import code
code.interact(local=locals())

Saturday, September 14, 2013

You have not chosen to trust "DigiCert High Assurance EV Root CA" Fix Ubuntu Linux

So I had to download the new Citrix receiver for my linux browser so I could remote in to some windows machines at work. After downloading the app, installing and logging in with my RSA key I get this error:


"SSL error
Contact your help desk with the folling information:
You have not chosen to trust "DigiCert High Assurance EV Root CA",
the issuer of the server's security certificate (SSL error 61)"

Whaatttt!! Are you serious! How stupid. So if I go to https://www.digicert.com/digicert-root-certificates.htm I can test my certificates and they work just fine for the DigiCert High Assurance check, so that means the browser knows where they are but the stupid Citrix app doesn't. So all of the certs are located here in Ubuntu (you have a ton in there):

ls /etc/ssl/certs/ | grep DigiCert

You will see the one you want, now copy it to your Citrix folder:


sudo cp -v /etc/ssl/certs/DigiCert_High_Assurance_EV_Root_CA.pem ~/./ICAClient/linuxx86/keystore/cacerts/

Now try again and it will work, I didn't even have to restart my browser. You could also do a symbolic link instead which is maybe a better practice. 


Friday, August 23, 2013

[Errno 14] PYCURL ERROR 7 - epel repo install not working RHEL 64 bit



Solution:
I added

proxy=http://proxyHost:proxyPort/
proxy_username=myUsername
proxy_password=myPassword

to

vi /etc/yum.conf

and it worked.

Original error:

 sudo yum --enablerepo=epel install R
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - "Failed to connect to 2610:28:3090:3001:dead:beef:cafe:fed4: Network is unreachable"
Trying other mirror.


was fixed

Wednesday, August 21, 2013

How to install ox_Oracle in RHEL 64 bit and get it working

Ok this sucked... but it is done now and hopefully this helps one person somewhere, please comment if it does.

So this is the version of RHEL I am using when I call uname -or
2.6.32-358.el6.x86_64 GNU/Linux

I didn't know what version of Oracle was running and so rather than asking the DBA I just ran this SQL statement in my developer tool: "Select * from v$version;"

which told me 10.2.0.5. So then I went over to Oracle's website for 64bit drivers:

http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html  (select the license agreement and download to /tmp/)

and download the basic 10.2.04 rpm to my /tmp/ folder

cd /tmp/
rpm -ivh oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm

after that was installed I needed to setup the environmental variables just right. If you don't do this your ox_Oracle install will fail silently and you will hit your head against the wall forever..

Tkae note your exact paths might be a little different so check them (incase you have a different version or didn't do the 64bit, etc..

echo export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.4/client64/lib/ >> ~/.bashrc
echo export ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client64 >> ~/.bashrc
echo export PATH=$ORACLE_HOME/bin:$PATH >> ~/.bashrc

This also throws them into the bashrc so they will be there next time. Now it is time to download the ox_Oracle RPM for python. For that go here: http://cx-oracle.sourceforge.net/

Even though I am using RHEL you can just use the CENTOS RPM. So pick your version of oracle and python. If you don't know your version of python run: python -V

wget http://downloads.sourceforge.net/project/cx-oracle/5.1/cx_Oracle-5.1-10g-py26-1.x86_64.rpm?r=http%3A%2F%2Fcx-oracle.sourceforge.net%2F&ts=1377121971&use_mirror=superb-dca2

Now install

rpm -ivh cx_Oracle-5.1-10g-py26-1.x86_64.rpm

Yay!! You did it! You are awesome! You saved hours and hours of time compared to everyone else that has tried this! Congrats, you are a genius, epic genius. Well... maybe... to really know if all of this is true try this:

python -c "import cx_Oracle"

If that works with no errors you did it! Now for some more robust testing try actually doing a simple select statement. Let's try the one we started with. Make a file called connect.py and put this in it.

vi connect.py

Once that opens then copy this in, and of course populate with your connection info. Then save.

import sys
import cx_Oracle

host='yourhostname'
sid='yourSID'
username='yourUserName'
password='yourPassWord'
dsn = cx_Oracle.makedsn(host, 1521, sid)
con = cx_Oracle.connect(username+'/'+password+'@' + dsn)
cur = con.cursor()

cur.execute('Select * from v$version')
for result in cur:
    print result
print con.version

cur.close()
con.close()
print "I am awesome!"

and test

python connect.py

Saturday, August 10, 2013

How to prevent parallel python from connecting to localhost

How to prevent parallel python from connecting to localhost How to exclude parallel python from using localhost To do this in your script that you are calling to kick of your jobs just set:

job_server = pp.Server(ncpus=0, ppservers=ppservers)

 By setting the number of CPUS to 0 you will not see anything startup and then you get something like this:


Starting pp with 0 workers
Sum of primes below 5 6 7 is node001
Sum of primes below 6 7 8 is node002
Sum of primes below 7 8 9 is node001
Sum of primes below 4 5 6 is node002
Sum of primes below 9 8 1 is node001
Sum of primes below 1 2 3 is node001
Sum of primes below 3 4 5 is node001
Sum of primes below 3 3 2 is node002
Job execution statistics:
Name:local
 job count | % of all jobs | job time sum | time per job | job server
         5 |         62.50 |       0.1804 |     0.036082 | node001:60000
         3 |         37.50 |       0.1753 |     0.058426 | node002:60000
Time elapsed since server creation 0.495481967926
0 active tasks, 0 cores


No localhost!

Thursday, February 21, 2013

How to start gateone.py service and logout

So I want to start this on my server and be able to logout. So I use this command:
sudo nohup python gateone.py &

For the server to work correctly I had to run as sudo

Then to see if it is still running, logout, and log back in through ssh and run this command
ps -ef | grep gateone

You should see this:
me@myserver:~$ ps -ef | grep gateone
root 4780 4761 0 06:47 pts/0 00:00:00 sudo nohup python gateone.py
snow 4788 4761 0 06:48 pts/0 00:00:00 grep --color=auto gateone

Saturday, February 2, 2013

How to convert csv to tab delimited linux command line

So this is how I converted csv to tab delimited on the command line:


 cat sports.csv | tr "," "\\t" > sports.txt