NumPy http://docs.scipy.org/doc/numpy/reference/
SciPy http://docs.scipy.org/doc/scipy/reference/
Stackless http://www.stackless.com/wiki
MatPlotLib http://matplotlib.org/contents.html
PIL http://pythonware.com/library/pil/handbook/
MLPy http://mlpy.sourceforge.net/docs/3.5/
PyMC http://pymc-devs.github.com/pymc/
Orange http://orange.biolab.si/docs/latest/
PyBrain http://pybrain.org/docs/
SciKit Learn http://scikit-learn.org/stable/user_guide.html
PyWin32 http://sourceforge.net/projects/pywin32/files/
PyWinAuto http://code.google.com/p/pywinauto/
PyPI http://pypi.python.org/pypi
50 Modules http://www.catswhocode.com/blog/python-50-modules-for-all-needs
Python 2.7 http://docs.python.org/2/
Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts
Saturday, 19 January 2013
Monday, 19 November 2012
How To Change System Date And Time in Python
import sys
import datetime
def _win_set_time(time_tuple):
import pywin32
# http://timgolden.me.uk/pywin32-docs/win32api__SetSystemTime_meth.html
# pywin32.SetSystemTime(year, month , dayOfWeek , day , hour , minute , second , millseconds )
dayOfWeek = datetime.datetime(time_tuple).isocalendar()[2]
pywin32.SetSystemTime( time_tuple[:2] + (dayOfWeek,) + time_tuple[2:])
def _linux_set_time(time_tuple):
import ctypes
import ctypes.util
import time
# /usr/include/linux/time.h:
#
# define CLOCK_REALTIME 0
CLOCK_REALTIME = 0
# /usr/include/time.h
#
# struct timespec
# {
# __time_t tv_sec; /* Seconds. */
# long int tv_nsec; /* Nanoseconds. */
# };
class timespec(ctypes.Structure):
_fields_ = [("tv_sec", ctypes.c_long),
("tv_nsec", ctypes.c_long)]
librt = ctypes.CDLL(ctypes.util.find_library("rt"))
ts = timespec()
ts.tv_sec = int( time.mktime( datetime.datetime( *time_tuple[:6]).timetuple() ) )
ts.tv_nsec = time_tuple[6] * 1000000 # Millisecond to nanosecond
# http://linux.die.net/man/3/clock_settime
librt.clock_settime(CLOCK_REALTIME, ctypes.byref(ts))
time_tuple = ( 2012, # Year
9, # Month
6, # Day
0, # Hour
38, # Minute
0, # Second
0, ) # Millisecond
if sys.platform=='linux2':
_linux_set_time(time_tuple)
elif sys.platform=='win32':
_win_set_time(time_tuple)
from: http://stackoverflow.com/questions/12081310/python-module-to-change-system-date-and-time
Subscribe to:
Posts (Atom)