Custom Search

Thursday, April 21, 2016

how to install python pycrypto

$pip install -d ~/mydir pycrypto

$cd mydir

$tar -xzf pycrypto-2.6.1.tar.gz

$sudo apt-get install python-dev

$sudo python setup.py install

python setup.py install raise RuntimeError("autoconf error") RuntimeError: autoconf error

$sudo apt-get install python-dev

$sudo python setup.py install

how to install python xmltodict

$pip install -d ~/mydir  xmltodict

$cd ~/mydir

$tar -xzf xmltodict-0.10.1.tar.gz

$sudo python setup.py install

Wednesday, April 20, 2016

How to github Check out pull requests locally

1)
Fetch PR 77 and save it in branch named "new_batch_name"
$git fetch origin pull/77/head:new_batch_name

2)
Got branch "new_batch_name"
$git checkout new_batch_name

3)
Check for all commits in the PR 77
$git log -n 5

fatal: unable to access server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

$ git config --global http.sslverify false

ubuntu add proxy to apt-get

a)
$sudo vim /etc/apt/apt.conf
Acquire::Http::Proxy "http://10.150.172.144:10000/";

b)
$sudo apt-get update

How to use lsof to find information about files opened by a process

1)
Open a file with vim editor and don't close it
$vim myfile1.txt

2)
Find PID of vim process
$ps -aux | grep vim
saju      6570  0.1  0.0  76332  6260 pts/10   Sl+  02:43   0:00 vim myfile1.txt

3)
check lsof the vim process and you can see the process opened one file
$sudo lsof -p 6570
vim     6570 saju    5u   REG    8,1    12288 17328734 /home/saju/testdownload/.myfile1.txt.swp

* Here 5u is the file descriptor (fd)

4)
Open another file in same vim editor with ":split myfile2.txt" command

5)
check lsof the process and you can see the process opened two files
$sudo lsof -p 6570
vim     6570 saju    5u   REG    8,1    12288 17328734 /home/saju/testdownload/.myfile1.txt.swp
vim     6570 saju    6u   REG    8,1    12288 17328754 /home/saju/testdownload/.myfile2.txt.swp

* Here 5u and 6u are the file descriptor (fd)

Ubuntu Linux Recover Deleted Files With lsof

1)
Create a file
$vim myfile1.txt

2)
Open that file with program "tail"
$tail -f myfile1.txt

3)
Delete that file
$rm myfile1.txt

4)
Find PID of process which opened "myfile1.txt"
$sudo lsof | grep myfile1.txt
OR
#ps -aux | grep tail

5)
Recover that file
$cp /proc/xxx/fd/4 myfile1.txt

* xxx is the PID of process which opened "myfile1.txt", this case it is "tail".



Sunday, April 3, 2016

openstack devstack/functions-common:1066 Failed to update apt repos, we're dead now

 1)
Error:

Get:55 http://us.archive.ubuntu.com trusty/restricted Sources [5433 B]        
Get:56 http://us.archive.ubuntu.com trusty/universe Sources [6399 kB]         
Get:57 http://us.archive.ubuntu.com trusty/multiverse Sources [174 kB]        
Get:58 http://us.archive.ubuntu.com trusty/main amd64 Packages [1350 kB]      
98% [58 Packages 1130 kB/1350 kB 84%]                              24.7 kB/s 8s++functions-common:apt_get_update:1066      die 1066 'Failed to update apt repos, we'\''re dead now'
++functions-common:die:186                  local exitcode=0
++functions-common:die:187                  set +o xtrace
[Call Trace]
./stack.sh:713:source
/home/python/devstack/tools/install_prereqs.sh:72:install_package
/home/python/devstack/functions-common:1276:update_package_repo
/home/python/devstack/functions-common:1257:apt_get_update
/home/python/devstack/functions-common:1066:die
[ERROR] /home/python/devstack/functions-common:1066 Failed to update apt repos, we're dead now
99% [58 Packages 1191 kB/1350 kB 88%]                              24.7 kB/s 6sError on exit
./stack.sh: line 488: generate-subunit: command not found
Get:59 http://us.archive.ubuntu.com trusty/restricted amd64 Packages [13.0 kB]
Get:60 http://us.archive.ubuntu.com trusty/universe amd64 Packages [5859 kB]  
Get:61 http://us.archive.ubuntu.com trusty/multiverse amd64 Packages [132 kB] 
Get:62 http://us.archive.ubuntu.com trusty/main i386 Packages [1348 kB]       
Get:63 http://us.archive.ubuntu.com trusty/restricted i386 Packages [13.4 kB] 
Get:64 http://us.archive.ubuntu.com trusty/universe i386 Packages [5866 kB]   
Get:65 http://us.archive.ubuntu.com trusty/multiverse i386 Packages [134 kB]  
Get:66 http://us.archive.ubuntu.com trusty/main Translation-en [762 kB]       
Get:67 http://us.archive.ubuntu.com trusty/multiverse Translation-en [102 kB] 
Get:68 http://us.archive.ubuntu.com trusty/restricted Translation-en [3457 B] 
Get:69 http://us.archive.ubuntu.com trusty/universe Translation-en [4089 kB]  
Fetched 32.6 MB in 11min 53s (45.8 kB/s)                                      
Reading package lists... Done

2)
Fix:
Open file "functions-common" and search for "dead" and change "timeout 300" to "timeout 1000"




Friday, April 1, 2016

Python http status codes from httplib

>>>
>>> from pprint import pprint
>>>
>>>
>>> import httplib
>>>
>>>
>>> pprint(httplib.responses)
{100: 'Continue',
 101: 'Switching Protocols',
 200: 'OK',
 201: 'Created',
 202: 'Accepted',
 203: 'Non-Authoritative Information',
 204: 'No Content',
 205: 'Reset Content',
 206: 'Partial Content',
 300: 'Multiple Choices',
 301: 'Moved Permanently',
 302: 'Found',
 303: 'See Other',
 304: 'Not Modified',
 305: 'Use Proxy',
 306: '(Unused)',
 307: 'Temporary Redirect',
 400: 'Bad Request',
 401: 'Unauthorized',
 402: 'Payment Required',
 403: 'Forbidden',
 404: 'Not Found',
 405: 'Method Not Allowed',
 406: 'Not Acceptable',
 407: 'Proxy Authentication Required',
 408: 'Request Timeout',
 409: 'Conflict',
 410: 'Gone',
 411: 'Length Required',
 412: 'Precondition Failed',
 413: 'Request Entity Too Large',
 414: 'Request-URI Too Long',
 415: 'Unsupported Media Type',
 416: 'Requested Range Not Satisfiable',
 417: 'Expectation Failed',
 500: 'Internal Server Error',
 501: 'Not Implemented',
 502: 'Bad Gateway',
 503: 'Service Unavailable',
 504: 'Gateway Timeout',
 505: 'HTTP Version Not Supported'}
>>>
>>>

How to Vagrant Virtualbox restart a Virtual Machine

How to Vagrant Virtualbox restart a VM

$VBoxManage list vms

$VBoxManage controlvm reset