03 Oct'13

Pelican on Windows

I enjoy using pelican so for so much. However, few issues hit my mind recently:

  • Medium is such a nice place to write that I can merely resist my temptation;
  • There is no ability to run person search across the static website;
  • I’m tied to UNIX environment in order to run the Pelican development server for preview.

I recalled a great quote:

Once you say you’re going to ...

Continue reading

05 Mar'12

Python hostname

from socket import gethostname

print gethostname()

if 'prod' in gethostname:

Continue reading

08 Feb'12

Generating keyboard events

import pyatspi
reg = pyatspi.Registry.generateKeyboardEvent
reg(36, None, pyatspi.KEY_preSSRELEASE) #Enter

Continue reading

Python chroot

What is important to remember is that chroot will allow you cd into /, and that will correspond to the dir you chrooted in:

for opt in glob.glob("/*"):
    print "\t-> %s" % opt

    print "Chroot FAIL"
    print os.getcwd()
except Exception as e:
    print "Chroot OK"

Continue reading

Nonblocking console input in Python

By Nemesis Fixx:

import sys
import select
import tty
import termios
from threading import Thread

program_run = True
input_thread_timeout = 0.005 #seconds
quit_key = '\x1b' # x1b is ESC

#check stdin for input...
def isData():
        return select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], [])

#check n terminate program on terminal condition,
#from a separate thread
class waitOnInput(Thread):
    def run(self):
        old_settings = termios.tcgetattr(sys.stdin)
            global program_run ...

Continue reading