Ejecutar Hotot desde el escritorio

Tras la instalación de hotot ( Cómo instalar hotot en opensuse 11.3), cree un acceso directo en el escritorio apuntando a donde estaba el ejecutable, en mi caso:
/home/dieguz2/Programas/hotot/hotot.py

Pero me daba los siguientes errores:
Traceback (most recent call last):
File "./hotot.py", line 302, in
main()
File "./hotot.py", line 285, in main
agent.init_notify()
File "/home/dieguz2/Programas/hotot/hotot/agent.py", line 87, in init_notify
utils.get_ui_object('imgs/ic64_hotot.png')))
TypeError: pixbuf_new_from_file() argument 1 must be string, not None

Aparentemente sólo podía ejecutar hotot desde el directorio:
/home/dieguz2/Programas/hotot/

y llamando a
./hotot/hotot.py

Si nos e hacia así no encontraba varios de sus recursos.

Para poder ejecutarlo desde cualquier sitio haremos lo siguiente
1) Creamos un archivo en el directorio de hotot. En mi caso el directorio es /home/dieguz2/Programas/hotot/. Le damos permisos de ejecución
touch /home/dieguz2/Programas/hotot/runfromhere.py
chmod u+x /home/dieguz2/Programas/hotot/runfromhere.py

2) Editamos dicho archivo (cat > /home/dieguz2/Programas/hotot/runfromhere.py) y le añadimos el siguiente contenido:
#!/usr/bin/env python
# Copyright (C) 2010 dieguz2
# License: GNU GPL v3
# http://dieguz2.blogspot.com/
# script: runfromhere.py
# description: change current working directory to the path where the script is and then execute COMMAND
import os
import sys

command="./hotot/hotot.py" # command we want to execute
dirname= os.path.dirname(os.path.abspath(sys.argv[0])) # get path where this script is
os.chdir(dirname)
os.system(command)
En este script obtenemos el path absoluto donde está el script ( no es el mismo que el path de llamada). Como dicho script está alojado en el home de hotot, cambiamos a dicho directorio y ejecutamos hotot desde ahí

3) Para ejecutar hotot desde el escritorio o desde cualquier sitio, ejecutaremos el archivo que hemos creado.
/home/dieguz2/Programas/hotot/runfromhere.py



Otra forma alternativa es crear un shell script (o en python) como el siguiente y colocarlo por ejemplo en nuestro ~/bin de usuario. En este caso pondremos en la variable hotot_path la ruta donde está instalado hotot:
touch ~/bin/hotot.sh
chmod u+x ~/bin/hotot.sh
cat > ~/bin/hotot.sh
#!/bin/sh
hotot_path=/home/dieguz2/Programas/hotot
cd $hotot_path
./hotot/hotot.py

Comentarios

Entradas populares de este blog

Compilar php 4.4 con ldap en centOs

Oracle : Tablas y objetos bloqueados