Entradas

[PYTHON] platform information script

import platform profile = [ platform.architecture(), platform.dist(), platform.libc_ver(), platform.mac_ver(), platform.machine(), platform.node(), platform.platform(), platform.processor(), platform.python_build(), platform.python_compiler(), platform.python_version(), platform.system(), platform.uname(), platform.version() ] def main(): for item in profile: print (item) if __name__ == '__main__': main()

[ORACLE] ASM script dfdg

# ------------------------------------------------------------------------------ # FUNCTION #   Displays ASM diskgroup information, space usage. Displays usage by DISKS. #   Displays ongoing operations and list of files on diskgroup. # NOTES #   Developed for 11g Oracle Version. The entry must be in the /etc/oratab #   for ASM instance # # ------------------------------------------------------------------------------ TMP1=`grep -E '^\+' /etc/oratab` if [ -z $TMP1 ]; then   echo "Please check /etc/oratab file, there is no entry for ASM instance."   exit 1 fi ORACLE_HOME=`echo ${TMP1//\:/ } | awk {'print $2'}` ORACLE_SID=`echo ${TMP1//\:/ } | awk {'print $1'}` cd $ORACLE_HOME/bin dispinfo () {  echo "Use -d key to display usage by disks"  echo "Use -o key to display asm operations in progress (disk rebalancing)"  echo "Use -r key to display min, max and avergage free megabytes by diskgroups"  echo "Use -f  to list ...

[PYTHON] Instalación de Easy Install

Easy Install es un módulo Python ( easy_install ), que forma parte de setuptools, para la gestión de paquetes python. Para la instalación en Windows, se recomienda utilizar el script ez_setup.py . Ahora bien, si tenemos dos instalaciones de Python en la misma máquina, por ejemplo: c:\python27 c:\python33 Y queremos instalar el paquete easy_install en las dos instalaciones o en una en concreto, hay que tener en cuenta que habrá que ejecutar el script ez_setup.py , con el ejecutable python.exe de la instalación sobre la que queremos instalar el paquete. Por ejemplo, si queremos instalar bajo la instalación C:\python33, ejecutaríamos lo siguiente desde la línea de comandos: c:\Python33>.\python.exe C:\Users\oscar\Downloads\ez_setup.py El script ez_setup.py ya se encarga de bajar el paquete correspondiente a nuestra plataforma y versión de python.

[Python] Ejemplo escritura en un fichero

def main(): principal = 1000 # Initial amount rate = 0.05 # Interest rate numyears = 5 # Number of years year = 1 f = open("C:\\Users\\oscar\\Documents\\out.txt","w") # Open file for writing while year >f,"%3d %0.2f" % (year,principal) ####python2 print("%3d %0.2f" % (year,principal),file=f) #python3 #otra forma: #f.write("%3d %0.2f\n" % (year,principal)) year += 1 f.close() if __name__ == '__main__': main()

[PYTHON] Envolver rsync

#!/usr/bin/env python #Envolver rsync para sincronizar directorios from subprocess import call import sys source = "/home/oracle/dir1/" target = "oracle@stan:/home/oracle/dir1" rsync = "rsync" arguments = "-a" cmd = "%s %s %s %s " % (rsync, arguments, source, target) def sync(): ret = call(cmd, shell=True) if ret != 0: print "rsync failed" sys.exit(1) sync()

[PYTHON] Communicating with a SQL*Plus process from Python

#!/usr/bin/python import os from subprocess import Popen, PIPE sqlplus = Popen(["sqlplus", "-S", "/", "as", "sysdba"], stdout=PIPE, stdin=PIPE) sqlplus.stdin.write("select sysdate from dual;"+os.linesep) sqlplus.stdin.write("select count(*) from all_objects;"+os.linesep) out, err = sqlplus.communicate() print out

[PYTHON] Python + Oracle

Imagen
Url´s: http://www.oracle.com/technetwork/topics/scripting-languages/whatsnew/index-083918.HTML http://www.oracle.com/technetwork/articles/dsl/mastering-oracle-python-1391323.HTML Obtener cx_Oracle: http://cx-oracle.sourceforge.net/ Instalar el paquete rpm correspondiente, por ejemplo:                                 rpm -ivhU cx_Oracle-5.1.2-10g-py26-1.x86_64.rpm Si se produce el siguiente error al lanzar el interprete de python: [oracle@oel6 ~]$ python Python 2.6.6 (r266:84292, Sep 11 2012, 05:13:24) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import cx_Oracle Traceback (most recent call last):   File " ", line 1, in ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory ...