This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import time | |
def time_zone(t): | |
if t.tm_isdst == 1 and time.daylight == 1: | |
tz_sec = time.altzone | |
tz_name = time.tzname[1] | |
else: | |
tz_sec = time.timezone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import zlib | |
import hashlib | |
class Adler32CheckSum(): | |
@staticmethod | |
def checksum(filename, blocksize=1048576): | |
value = 1 | |
with open(filename, "rb") as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_terminal_size_linux(): | |
def ioctl_GWINSZ(fd): | |
try: | |
import fcntl, termios, struct | |
cr = struct.unpack('hh', | |
fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) | |
return cr | |
except: | |
pass | |
cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def loadObject(moduleName, className): | |
try: | |
m = __import__(moduleName, globals(), locals(), [className]) | |
except ImportError, e: | |
raise Exception('Could not from %s import %s' % (moduleName, className)) | |
return getattr(m, className)() | |
import imp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
get_python_version() { | |
version_str=$(python -V 2>&1) | |
temp=${version_str##* } | |
python_version_major=${temp%%.*} | |
temp=${temp#*.} | |
python_version_minor=${temp%%.*} | |
} |