# apt-get install python-notify
or
# pip install py-notify
# apt-get install python-notify2
or
# pip install notify2
References :
[pygtk] ImportError for pynotify?
# apt-get install python-notify
or
# pip install py-notify
# apt-get install python-notify2
or
# pip install notify2
import wx
app = wx.App(0)
x = wx.GetDisplaySize()[0]
y = wx.GetDisplaySize()[1]
import thread thread.start_new_thread(os.system,('cmd',))
from bbfreeze import Freezer
f = Freezer("dir-name", includes=("_strptime",))
f.addScript("main.py")
f()
import wx
import wx.html
if __name__ == "__main__" :
app = wx.App()
frame = wx.Frame(None)
htmlwin = wx.html.HtmlWindow(frame)
htmlwin.SetPage("Hello, World !
")
frame.Show()
app.MainLoop()
content = unicode(content,'Big5','ignore').encode('utf-8','ignore')
import win32api
import win32security from ntsecuritycon import *
def AdjustPrivilege(priv, enable = 1):
# Get the process token.
flags = TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY
htoken = win32security.OpenProcessToken(win32api.GetCurrentProcess(), flags)
# Get the ID for the system shutdown privilege.
id = win32security.LookupPrivilegeValue(None, priv)
# Now obtain the privilege for this process.
# Create a list of the privileges to be added.
if enable:
newPrivileges = [(id, SE_PRIVILEGE_ENABLED)]
else:
newPrivileges = [(id, 0)]
# and make the adjustment.
win32security.AdjustTokenPrivileges(htoken, 0, newPrivileges)
def Halt(sec = 1):
AdjustPrivilege(SE_SHUTDOWN_NAME)
try:
win32api.InitiateSystemShutdown(None, "System will shutdown.", sec, 1, 0) # lpMachineName, lpMessage, dwTimeout, bForceAppsClosed, bRebootAfterShutdown
finally:
# Now we remove the privilege we just added.
AdjustPrivilege(SE_SHUTDOWN_NAME, 0)
def Reboot(sec = 1):
#subprocess.Popen('shutdown -r -t %s -c "System will reboot."' % (sec),
# stdout=subprocess.PIPE).communicate()[0]
AdjustPrivilege(SE_SHUTDOWN_NAME)
try:
win32api.InitiateSystemShutdown(None, 'System will reboot.', sec, 1, 1) # lpMachineName, lpMessage, dwTimeout, bForceAppsClosed, bRebootAfterShutdown
finally:
# Now we remove the privilege we just added.
AdjustPrivilege(SE_SHUTDOWN_NAME, 0)
import ctypes
ctypes.windll.user32.ExitWindowsEx(0, 1)
import ctypes
ctypes.windll.user32.LockWorkStation()
from distutils.core import setup
import win32service
import win32serviceutil
import py2exe
setup(service=["ProductCollectWin32Service"])
鹹
|
酸
|
油
|
辛香料
|
鹽、醬油、味噌
|
紅酒醋、白醋、檸檬汁、柚子汁
|
橄欖油、沙拉油、麻油、核桃油
|
蔥、薑、蒜、辣椒、香草
|
from distutils.core import setup
import win32service
import win32serviceutil
import py2exe
setup(service=["ProductCollectWin32Service"])
import win32serviceutil
win32serviceutil.StartService('Server')
Reference :
Manipulating Windows Services « Python recipes « ActiveState Code
import logging
logger = logging.getLogger() # 預設是 root
#logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('/tmp/test.log')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr) # 設定 Log 記錄到檔案裡
logger.setLevel(logging.NOTSET) # 設定記錄的等級
logger.debug('teeessst')
print urllib2.unquote('%3A%3B%28%29%24%26%40%22.%2C')
Reference :
URL encoding/decoding with Python - Stack Overflow
self.frame.SetBackgroundColour( (255,255,0) )