Keystroke Description
Press X during startup Force Mac OS X startup
Press Option-Command-Shift-Delete
during startup Bypass primary startup volume and seek a different startup volume (such as a CD or external disk)
Press C during startup Start up from a CD that has a system folder
Press N during startup Attempt to start up from a compatible network server (NetBoot)
Press R during startup Force PowerBook screen reset
Press T during startup Start up in FireWire Target Disk mode
Press Shift during startup start up in Safe Boot mode and temporarily disable login items and non-essential kernel extension files (Mac OS X 10.2 and later)
Press Command-V during startup Start up in Verbose mode.
Press Command-S during startup Start up in Single-User mode (command line)

creating windows service using pyinstaller

copied from

# Usage: 
# service.exe install
# service.exe start
# service.exe stop
# service.exe remove

# you can see output of this program running python site-packages\win32\lib\win32traceutil 

import win32service

import win32serviceutil
import win32event
import win32evtlogutil
import win32traceutil
import servicemanager
import winerror
import time
import sys

class aservice(win32serviceutil.ServiceFramework):

    _svc_name_ = "aservice"
    _svc_display_name_ = "aservice - It Does nothing"
    _svc_deps_ = ["EventLog"]

    def __init__(self,args):

        self.hWaitStop=win32event.CreateEvent(None, 0, 0, None)

    def SvcStop(self):

        # tell Service Manager we are trying to stop (required)

    # write a message in the SM (optional)
        # import servicemanager
        # servicemanager.LogInfoMsg("aservice - Recieved stop signal")

    # set the event to call


    def SvcDoRun(self):
        import servicemanager
        # Write a 'started' event to the event log... (not required)
servicemanager.EVENTLOG_INFORMATION_TYPE,(self._svc_name_, ''))

        # methode 1: wait for beeing stopped ... 
        # win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)

        # methode 2: wait for beeing stopped ...
        self.timeout=1000  # In milliseconds (update every second) 

        while self.isAlive:

            # wait for service stop signal, if timeout, loop again
            rc=win32event.WaitForSingleObject(self.hWaitStop, self.timeout) 

            print "looping"

        # and write a 'stopped' event to the event log (not required)
servicemanager.EVENTLOG_INFORMATION_TYPE,(self._svc_name_, ''))



if __name__ == '__main__':

    # if called without argvs, let's run !

    if len(sys.argv) == 1:

        evtsrc_dll = os.path.abspath(servicemanager.__file__)
        servicemanager.Initialize('aservice', evtsrc_dll)

        except win32service.error, details:
            if details[0] == winerror.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT:

Get the windows service state using Python

following code can be used to find if any service is installed and if so then return the state of the service.

import wmi

class servicePython():
    def __init__(self, serviceName):
        self.c = wmi.WMI ()
        self.serviceName = serviceName

    def setServiceName(self, serviceName):
        self.serviceName = serviceName

    def getStatus(self):    
        srv = c.Win32_Service (name=self.serviceName)
        if srv != []:
            return c.Status
        return False

recursive list files in a dir using Python

use the following code to list the files in a dir tree

import os
import sys
fileList = []
rootdir = sys.argv[1]
for root, subFolders, files in os.walk(rootdir):
    for file in files:
print fileList

# List of all the files, total count of files and folders & Total size of files.
import os
import sys

fileList = []
fileSize = 0
folderCount = 0
rootdir = sys.argv[1]

for root, subFolders, files in os.walk(rootdir):
    folderCount += len(subFolders)
    for file in files:
        f = os.path.join(root,file)
        fileSize = fileSize + os.path.getsize(f)

print("Total Size is {0} bytes".format(fileSize))
print(“Total Files “, len(fileList))
print(“Total Folders “, folderCount)