예제 #1
0
def main(argv = None):
    global options



    opts, args = process_options(argv)
    options = opts

    loglevel = {
        'CRITICAL' : logging.CRITICAL,
        'ERROR' : logging.ERROR,
        'INFO' : logging.INFO,
        'WARNING' : logging.WARNING,
        'DEBUG' : logging.DEBUG
        }[opts.loglevel]

    if opts.show_console:
        print "Showing console"
        logging.basicConfig( level = loglevel )
    else:
        print "Hiding console"
        print "Logging into '%s'" % os.path.join(ENSO_DIR, "enso.log")
        sys.stdout = open("stdout.log", "w", 0) #NullDevice()
        sys.stderr = open("stderr.log", "w", 0) #NullDevice()
        logging.basicConfig(
            filename = os.path.join(ENSO_DIR, "enso.log"),
            level = loglevel )

    if loglevel == logging.DEBUG:
        print opts
        print args

    ensorcPath = os.path.expanduser("~/.ensorc")
    if os.path.exists( ensorcPath ):
        logging.info( "Loading '%s'." % ensorcPath )
        contents = open( ensorcPath, "r" ).read()
        compiledContents = compile( contents + "\n", ensorcPath, "exec" )
        exec compiledContents in {}, {}

#    if not opts.quiet and opts.show_splash:
#        displayMessage("<p>Starting <command>Enso</command>...</p>")

    if opts.show_tray_icon:
        # Execute tray-icon code in separate thread
        threading.Thread(target = systray, args = (enso.config,)).start()

    enso.run()

    return 0
예제 #2
0
def main(argv=None):
    global options

    opts, args = process_options(argv)
    options = opts

    loglevel = {
        'CRITICAL': logging.CRITICAL,
        'ERROR': logging.ERROR,
        'INFO': logging.INFO,
        'WARNING': logging.WARNING,
        'DEBUG': logging.DEBUG
    }[opts.loglevel]

    if opts.show_console:
        print "Showing console"
        logging.basicConfig(level=loglevel)
    else:
        print "Hiding console"
        print "Logging into '%s'" % os.path.join(ENSO_DIR, "enso.log")
        sys.stdout = open("stdout.log", "w", 0)  #NullDevice()
        sys.stderr = open("stderr.log", "w", 0)  #NullDevice()
        logging.basicConfig(filename=os.path.join(ENSO_DIR, "enso.log"),
                            level=loglevel)

    if loglevel == logging.DEBUG:
        print opts
        print args

    ensorcPath = os.path.expanduser("~/.ensorc")
    if os.path.exists(ensorcPath):
        logging.info("Loading '%s'." % ensorcPath)
        contents = open(ensorcPath, "r").read()
        compiledContents = compile(contents + "\n", ensorcPath, "exec")
        exec compiledContents in {}, {}


#    if not opts.quiet and opts.show_splash:
#        displayMessage("<p>Starting <command>Enso</command>...</p>")

    if opts.show_tray_icon:
        # Execute tray-icon code in separate thread
        threading.Thread(target=systray, args=(enso.config, )).start()

    enso.run()

    return 0
예제 #3
0
#! /usr/bin/env python

import os
import logging

import enso

if __name__ == "__main__":
    logging.basicConfig( level=logging.INFO )

    # TODO: os.getenv( "HOME" ) only works 'out-of-the-box' on
    # unix; we need to do something different, preferably
    # in platform-specific backends.
    homeDir = os.getenv( "HOME" )
    if homeDir:
        ensorcPath = os.path.join( homeDir, ".ensorc" )
        if os.path.exists( ensorcPath ):
            logging.info( "Loading '%s'." % ensorcPath )
            contents = open( ensorcPath, "r" ).read()
            compiledContents = compile( contents, ensorcPath, "exec" )
            exec compiledContents in {}, {}

    enso.run()
예제 #4
0
def main(argv = None):
    opts, args = process_options(argv)
    config.ENSO_IS_QUIET = opts.quiet

    loglevel = {
        'CRITICAL' : logging.CRITICAL,
        'ERROR' : logging.ERROR,
        'INFO' : logging.INFO,
        'WARNING' : logging.WARNING,
        'DEBUG' : logging.DEBUG
        }[opts.loglevel]

    if opts.show_console:
        print("Showing console")
        logging.basicConfig( level = loglevel )
    else:
        print("Hiding console")
        user_log = os.path.join(config.ENSO_USER_DIR, "enso.log")
        print("Logging into '%s'" % user_log)
        sys.stdout = open(user_log, "w") #NullDevice()
        sys.stderr = open(user_log, "w") #NullDevice()
        logging.basicConfig(
            filename = user_log,
            level = loglevel )

    if loglevel == logging.DEBUG:
        print(opts)
        print(args)

    if not os.path.isdir(config.ENSO_USER_DIR):
        os.makedirs(config.ENSO_USER_DIR)

    user_lib_dir = os.path.join(config.ENSO_USER_DIR, "lib")
    if not os.path.isdir(user_lib_dir):
        os.makedirs(user_lib_dir)

    user_commands_dir = os.path.join(config.ENSO_USER_DIR, "commands")
    user_commands = os.path.join(user_commands_dir, "user.py")

    if not os.path.isdir(user_commands_dir):
        os.makedirs(user_commands_dir)

    open(user_commands, 'a').close()

    default_enso_rc = os.path.join(config.ENSO_USER_DIR, "ensorc.py")
    if not os.path.exists( default_enso_rc ):
        shutil.copyfile(os.path.join(config.ENSO_DIR, "scripts", "ensorc.py.default"),
                        os.path.join(config.ENSO_USER_DIR, "ensorc.py"))

    load_rc_config(default_enso_rc)

    # legacy ensorc, currently undocumented
    load_rc_config(os.path.expanduser("~/.ensorc"))

    if opts.show_tray_icon:
        # Execute tray-icon code in separate thread
        threading.Thread(target = systray, args = (config,)).start()

    retreat.start()

    enso.run()

    config.SYSTRAY_ICON.change_tooltip("Closing Enso...")
    if not config.ENSO_IS_QUIET:
        displayMessage("<p>Closing Enso...</p><caption>Enso</caption>")

    win32gui.PostMessage(config.SYSTRAY_ICON.hwnd, win32con.WM_COMMAND, config.SYSTRAY_ICON.CMD_FINALIZE, 0)

    retreat.stop()

    time.sleep(1)
    os._exit(0)

    return 0
예제 #5
0
def main(argv=None):
    opts, args = process_options(argv)
    config.ENSO_IS_QUIET = opts.quiet

    loglevel = {
        'CRITICAL': logging.CRITICAL,
        'ERROR': logging.ERROR,
        'INFO': logging.INFO,
        'WARNING': logging.WARNING,
        'DEBUG': logging.DEBUG
    }[opts.loglevel]

    if opts.show_console:
        print("Showing console")
        logging.basicConfig(level=loglevel)
    else:
        print("Hiding console")
        user_log = os.path.join(config.ENSO_USER_DIR, "enso.log")
        print("Logging into '%s'" % user_log)
        sys.stdout = open(user_log, "w")  #NullDevice()
        sys.stderr = open(user_log, "w")  #NullDevice()
        logging.basicConfig(filename=user_log, level=loglevel)

    if loglevel == logging.DEBUG:
        print(opts)
        print(args)

    if not os.path.isdir(config.ENSO_USER_DIR):
        os.makedirs(config.ENSO_USER_DIR)

    user_lib_dir = os.path.join(config.ENSO_USER_DIR, "lib")
    if not os.path.isdir(user_lib_dir):
        os.makedirs(user_lib_dir)

    user_commands_dir = os.path.join(config.ENSO_USER_DIR, "commands")
    user_commands = os.path.join(user_commands_dir, "user.py")

    if not os.path.isdir(user_commands_dir):
        os.makedirs(user_commands_dir)

    open(user_commands, 'a').close()

    default_enso_rc = os.path.join(config.ENSO_USER_DIR, "ensorc.py")
    if not os.path.exists(default_enso_rc):
        shutil.copyfile(
            os.path.join(config.ENSO_DIR, "scripts", "ensorc.py.default"),
            os.path.join(config.ENSO_USER_DIR, "ensorc.py"))

    load_rc_config(default_enso_rc)

    # legacy ensorc, currently undocumented
    load_rc_config(os.path.expanduser("~/.ensorc"))

    if opts.show_tray_icon:
        # Execute tray-icon code in separate thread
        threading.Thread(target=systray, args=(config, )).start()

    retreat.start()

    enso.run()

    config.SYSTRAY_ICON.change_tooltip("Closing Enso...")
    if not config.ENSO_IS_QUIET:
        displayMessage("<p>Closing Enso...</p><caption>Enso</caption>")

    win32gui.PostMessage(config.SYSTRAY_ICON.hwnd, win32con.WM_COMMAND,
                         config.SYSTRAY_ICON.CMD_FINALIZE, 0)

    retreat.stop()

    time.sleep(1)
    os._exit(0)

    return 0
예제 #6
0
파일: run_enso.py 프로젝트: cwsquared/enso
#! /usr/bin/env python

import os
import logging

import enso

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)

    # TODO: os.getenv( "HOME" ) only works 'out-of-the-box' on
    # unix; we need to do something different, preferably
    # in platform-specific backends.
    homeDir = os.getenv("HOME")
    if homeDir:
        ensorcPath = os.path.join(homeDir, ".ensorc")
        if os.path.exists(ensorcPath):
            logging.info("Loading '%s'." % ensorcPath)
            contents = open(ensorcPath, "r").read()
            compiledContents = compile(contents, ensorcPath, "exec")
            exec compiledContents in {}, {}

    enso.run()