Ejemplo n.º 1
0
    def log(self, message=None, locator=None):
        if not self.state:
            return

        if message is not None:
            self._entry.line(message)

        meta = self._entry.meta
        
        if locator is None:
            locator = here(1)

        # These are required by 'journal.devices.Renderer'.
        meta["filename"] = ""
        meta["function"] = ""
        meta["line"] = ""
        
        locator.getAttributes(meta)

        meta["facility"] = self.facility
        meta["severity"] = self.severity

        journal.journal().record(self._entry)

        if self.fatal:
            raise self.Fatal(message)
     
        self._entry = Entry()
        return self
Ejemplo n.º 2
0
    def log(self, message=None):
        if not self.state:
            return

        if message is not None:
            self._entry.line(message)

        stackDepth = -2
        stackTrace = traceback.extract_stack()
        file, line, function, src = stackTrace[stackDepth]

        meta = self._entry.meta
        meta["facility"] = self.facility
        meta["severity"] = self.severity
        meta["filename"] = file
        meta["function"] = function
        meta["line"] = line
        meta["src"] = src
        meta["stack-trace"] = stackTrace[:stackDepth+1]

        journal.journal().record(self._entry)

        if self.fatal:
            raise self.Fatal(message)
     
        self._entry = Entry()
        return self
Ejemplo n.º 3
0
    def log(self, message=None, locator=None):
        if not self.state:
            return

        if message is not None:
            self._entry.line(message)

        meta = self._entry.meta

        if locator is None:
            locator = here(1)

        # These are required by 'journal.devices.Renderer'.
        meta["filename"] = ""
        meta["function"] = ""
        meta["line"] = ""

        locator.getAttributes(meta)

        meta["facility"] = self.facility
        meta["severity"] = self.severity

        journal.journal().record(self._entry)

        if self.fatal:
            raise self.Fatal(message)

        self._entry = Entry()
        return self
Ejemplo n.º 4
0
    def log(self, message=None):
        if not self._state:
            return

        if message is not None:
            self._entry.line(message)

        stackDepth = -2
        stackTrace = traceback.extract_stack()
        file, line, function, src = stackTrace[stackDepth]

        meta = self._entry.meta
        meta["category"] = self.name
        meta["facility"] = self.facility
        meta["filename"] = file
        meta["function"] = function
        meta["line"] = line
        meta["src"] = src
        meta["stack-trace"] = stackTrace[:stackDepth + 1]

        journal.journal().record(self._entry)

        if self._fatal:
            raise self.Fatal

        self._entry = Entry()
        return self
Ejemplo n.º 5
0
def server(port, timeout):
    import select
    import socket
    import pickle
    import journal
    from journal.Entry import Entry
    import pyre.network

    # create the monitor
    monitor = pyre.network.monitor("udp")

    # install the monitor
    # the returned port may not be the same as we requested
    port, s = monitor.install(port, "")
    file = s.makefile("rb")

    while 1:
        reads, writes, excepts = select.select([s], [], [], timeout)
        if not reads:
            print " -- timeout"
            continue
        
        entry = pickle.load(file)
        journal.journal().record(entry)

    return
Ejemplo n.º 6
0
    def init(self, channel, defaultState, fatal=False):
        self._index = {}
        self._channel = channel
        self._defaultState = defaultState
        self._fatal = fatal

        import journal
        journal.journal().channel(channel, self)

        return
Ejemplo n.º 7
0
    def _init(self, parent):
        import journal
        component = journal.journal()
        device = self.inventory.device.device
        component.device = device

        return
Ejemplo n.º 8
0
    def __init__(self, default=None):
        if default is None:
            import journal
            default = journal.journal()

        Facility.__init__(self, "journal", default=default)
        ScriptBinder.__init__(self)
        return
Ejemplo n.º 9
0
    def updateConfiguration(self, registry):
        from pyre.util.bool import bool
        listing = self._listing(registry)

        for category, state in listing:
            journal.journal().channel(self.name).diagnostic(category).state = bool(state)
            
        return []
Ejemplo n.º 10
0
 def __call__(self, msg):
     import journal
     r = journal.journal().device.renderer
     header, footer, format = r.header, r.footer, r.format
     r.header, r.footer, r.format = self.header, self.footer, self.format
     getattr(journal, self.type)(self.name).log(msg) # journal.info('abc').log()
     r.header, r.footer, r.format = header, footer, format
     return
Ejemplo n.º 11
0
    def configure(self, registry):
        from pyre.util.bool import bool
        listing = self._listing(registry)

        for category, state in listing:
            journal.journal().channel(self.name).diagnostic(category).state = bool(state)
            
        return []
Ejemplo n.º 12
0
    def login():
        c = mydb.cursor()
        try:
            clear()
            username = input("Please enter your username: "******"SELECT * FROM user WHERE username = '******';"
            c.execute(command)
            check = c.fetchone()
            if check == None:
                print("Username not found. Please try again.")
                input()
                login()
            else:
                password = getpass.getpass("Please enter your password: "******"SELECT * FROM user WHERE username = ?;")
                command = f"SELECT * FROM user WHERE username = '******' AND password = '******';"
                c.execute(command)
                check = c.fetchone()
                if check == None:
                    print("Invalid Password. Try again")
                    input()
                    login()
                else:
                    command = f"SELECT userid FROM user WHERE username = '******' AND password = '******';"
                    c.execute(command)
                    userid = str(c.fetchone())
                    userid = userid[1:-2]
                    clear()
                    journal.journal(userid)
                    # print("Press 'ctrl + c' to exit")
                    # print("Enter 1 to add journal entries")
                    # print("Entre 2 to check balances in accounts")
                    # choice = input("> ")
                    # if choice == '1':
                    #     journal.journal(a)
                    # elif choice == '2':
                    #     journal.balance_check(a)
                    mydb.commit()
                    mydb.close()

        except KeyboardInterrupt:
            main()
        
        mydb.close()
Ejemplo n.º 13
0
    def record(self):
        if not self.state:
            return

        meta = self._entry.meta
        meta["facility"] = self.facility
        meta["severity"] = self.severity
        meta.setdefault("filename", "<unknown>")
        meta.setdefault("function", "<unknown>")
        meta.setdefault("line", "<unknown>")

        journal.journal().record(self._entry)

        if self.fatal:
            raise self.Fatal()
     
        self._entry = Entry()
        return self
Ejemplo n.º 14
0
    def record(self):
        if not self.state:
            return

        meta = self._entry.meta
        meta["facility"] = self.facility
        meta["severity"] = self.severity
        meta.setdefault("filename", "<unknown>")
        meta.setdefault("function", "<unknown>")
        meta.setdefault("line", "<unknown>")

        journal.journal().record(self._entry)

        if self.fatal:
            raise self.Fatal()

        self._entry = Entry()
        return self
Ejemplo n.º 15
0
    def _init(self):
        import journal
        theJournal = journal.journal()

        device = self.inventory.device.device
        theJournal.device = device

        Component._init(self)

        return
Ejemplo n.º 16
0
    def _init(self):
        import journal
        theJournal = journal.journal()

        device = self.inventory.device.device
        theJournal.device = device

        Component._init(self)

        return
Ejemplo n.º 17
0
    class Inventory(Component.Inventory):

        from ChannelFacility import ChannelFacility
        from DeviceFacility import DeviceFacility

        inventory = [
            ChannelFacility(channel)
            for channel in journal.journal().channels()
        ] + [
            DeviceFacility(),
        ]
Ejemplo n.º 18
0
def getJournal(username):

    createJournalFileIfNotExists(username)
    journalDataList = []
    with open('journals/' + username + ".txt", 'r') as f:
        while True:
            timestamp = f.readline().rstrip()
            entry = f.readline().rstrip()
            if not entry:
                break
            currentEntry = journal(timestamp, entry, username)
            journalDataList.append(currentEntry)

    return journalDataList
Ejemplo n.º 19
0
def test():
    import journal
    # force the initialization
    journal.journal()

    from jtest import jtest

    print " ** testing informationals"
    info = journal.info("jtest")
    info.activate()
    info.log("this is an info from python")
    jtest.info("jtest")

    print " ** testing warnings"
    warning = journal.warning("jtest")
    warning.log("this a warning from python")
    #jtest.warning("jtest")

    print " ** testing errors"
    error = journal.error("jtest")
    error.log("this an error from python")
    #jtest.error("jtest")

    return
Ejemplo n.º 20
0
def test():
    import journal
    # force the initialization
    journal.journal()

    from jtest import jtest

    print " ** testing informationals"
    info = journal.info("jtest")
    info.activate()
    info.log("this is an info from python")
    jtest.info("jtest")

    print " ** testing warnings"
    warning = journal.warning("jtest")
    warning.log("this a warning from python")
    #jtest.warning("jtest")

    print " ** testing errors"
    error = journal.error("jtest")
    error.log("this an error from python")
    #jtest.error("jtest")

    return
Ejemplo n.º 21
0
def test():
    import journal

    # install our renderer
    renderer = Logger()
    journal.journal().device.renderer = renderer

    info = journal.info("test")
    info.log("Hello world not!")
    info.activate()
    info.log("Hello world!")
    info.deactivate()
    info.log("Hello world again!")

    return
Ejemplo n.º 22
0
def test():
    import journal

    # install our renderer
    renderer = Logger()
    journal.journal().device.renderer = renderer

    info = journal.info("test")
    info.log("Hello world not!")
    info.activate()
    info.log("Hello world!")
    info.deactivate()
    info.log("Hello world again!")

    return
Ejemplo n.º 23
0
    def test_textfile(self):
        from journal.devices.TextFile import TextFile

        filename = "debug.log"
        with open(filename, "w") as log:
            journal.journal().device = TextFile(log)
            self.journal.log("Hello")

        with open(filename, "r") as log:
            logLines = log.readlines()
            iLog = 1
            self.assertEqual(">> test(debug)", logLines[iLog].strip())
            iLog += 1
            self.assertEqual("-- Hello", logLines[iLog].strip())
            iLog += 1
        os.remove(filename)
Ejemplo n.º 24
0
def createJournal(username):

    key = readKey()
    fernetKey = Fernet(key)
    text = input("Write your new entry: ")
    encodeText = text.encode('utf-8')
    encryptedText = fernetKey.encrypt(encodeText)
    currentTime = time.time()
    journalDataList = getJournal(username)
    journalEntry = journal(currentTime, encryptedText, username)
    if len(journalDataList) == 3:
        journalDataList.pop(0)
        journalDataList.append(journalEntry)
        overwriteJournalEntry(journalDataList)
    else:
        saveJournalEntry(journalEntry)
    print("Saved your entry in the journal")
Ejemplo n.º 25
0
    def serve(self, timeout=10):
        import pickle
        import select
        from journal.Entry import Entry

        import journal
        theJournal = journal.journal()
        file = self.monitor.socket.makefile("rb")

        while 1:
            reads, writes, excepts = select.select([file], [], [], timeout)
            if not reads:
                self._idle()
                continue

            entry = pickle.load(file)
            theJournal.record(entry)

        return
    def __init__(self, master, config):
        #display options
        row = 2
        PADX = 8
        PADY = 3

        self.totalMsg = 0
        self.messages = []
        self.hashlist = []
        self.cargoCount = "0"
        self.colors = []
        self.config = config
        self.run = True
        self.connected = False
        self.soundplayer = sound()
        self.checkBoxes = []
        self.entryStatList = [
            "ProspectedAsteroid", "StartJump", "SupercruiseExit"
        ]
        try:
            self.journal = journal()
        except ValueError as e:
            print(e)
            quit()

        #setup ui
        backgroundColor = self.config.config['ui_colors']['backgroundColor']
        textColor = self.config.config['ui_colors']['textColor']
        boxColor = self.config.config['ui_colors']['boxColor']
        boxTextColor = self.config.config['ui_colors']['boxTextColor']

        self.w = master
        self.w.title("EliteProspecting")
        self.w.protocol("WM_DELETE_WINDOW", self.closing)
        self.w.bind("<Return>", self.saveSettings)
        self.w.resizable(False, False)
        self.w.configure(background=backgroundColor)
        self.tLtd = tk.IntVar(value=self.config.config['mining']['track_ltd'])
        self.tPainite = tk.IntVar(
            value=self.config.config['mining']['track_painite'])
        self.sound = tk.IntVar(value=self.config.config['ui']['sound'])
        self.trans = tk.IntVar(value=self.config.config['ui']['transparency'])
        self.collect = tk.IntVar(value=self.config.config['server']['collect'])
        self.onlineD = tk.IntVar(value=self.config.config['ui']['online'])
        self.overlay = tk.IntVar(
            value=self.config.config['ui']['show_overlay'])
        self.cargo = tk.IntVar(
            value=self.config.config['mining']['track_cargo'])

        self.ipLabel = tk.Label(self.w,
                                text="Server IP",
                                background=backgroundColor,
                                foreground=textColor)
        self.ipAddr = tk.Entry(self.w,
                               background=boxColor,
                               foreground=boxTextColor)
        self.ipLabel.grid(row=row, padx=PADX, sticky=tk.W)
        self.ipAddr.grid(row=row, column=1, padx=PADX, pady=PADY, sticky=tk.EW)

        row += 1
        self.portLabel = tk.Label(self.w,
                                  text="Server Port",
                                  background=backgroundColor,
                                  foreground=textColor)
        self.port = tk.Entry(self.w,
                             background=boxColor,
                             foreground=boxTextColor)
        self.portLabel.grid(row=row, padx=PADX, sticky=tk.W)
        self.port.grid(row=row, column=1, padx=PADX, pady=PADY, sticky=tk.EW)

        row += 1
        self.roomLabel = tk.Label(self.w,
                                  text="Server Room",
                                  background=backgroundColor,
                                  foreground=textColor)
        self.room = tk.Entry(self.w,
                             background=boxColor,
                             foreground=boxTextColor)
        self.roomLabel.grid(row=row, padx=PADX, sticky=tk.W)
        self.room.grid(row=row, column=1, padx=PADX, pady=PADY, sticky=tk.EW)

        row += 1
        self.myColorLabel = tk.Label(self.w,
                                     text="My Color",
                                     background=backgroundColor,
                                     foreground=textColor)
        self.myColor = tk.Entry(self.w,
                                background=boxColor,
                                foreground=boxTextColor)
        self.myColorLabel.grid(row=row, padx=PADX, sticky=tk.W)
        self.myColor.grid(row=row,
                          column=1,
                          padx=PADX,
                          pady=PADY,
                          sticky=tk.EW)

        row += 1
        self.otherColorLabel = tk.Label(self.w,
                                        text="Other's Color",
                                        background=backgroundColor,
                                        foreground=textColor)
        self.otherColor = tk.Entry(self.w,
                                   background=boxColor,
                                   foreground=boxTextColor)
        self.otherColorLabel.grid(row=row, padx=PADX, sticky=tk.W)
        self.otherColor.grid(row=row,
                             column=1,
                             padx=PADX,
                             pady=PADY,
                             sticky=tk.EW)

        row += 1
        self.fontLabel = tk.Label(self.w,
                                  text="Font size",
                                  background=backgroundColor,
                                  foreground=textColor)
        self.font = tk.Entry(self.w,
                             background=boxColor,
                             foreground=boxTextColor)
        self.fontLabel.grid(row=row, padx=PADX, sticky=tk.W)
        self.font.grid(row=row, column=1, padx=PADX, pady=PADY, sticky=tk.EW)

        row += 1
        self.lineLabel = tk.Label(self.w,
                                  text="Lines number",
                                  background=backgroundColor,
                                  foreground=textColor)
        self.line = tk.Entry(self.w,
                             background=boxColor,
                             foreground=boxTextColor)
        self.lineLabel.grid(row=row, padx=PADX, sticky=tk.W)
        self.line.grid(row=row, column=1, padx=PADX, pady=PADY, sticky=tk.EW)

        row += 1
        self.ltdCB = tk.Checkbutton(self.w,
                                    text='Track LDT greater than',
                                    variable=self.tLtd,
                                    background=backgroundColor,
                                    foreground=textColor,
                                    command=self.onCheck)
        self.ltdCB.grid(row=row, padx=PADX, pady=PADY, sticky=tk.W)
        self.ltdThreshold = tk.Entry(self.w,
                                     background=boxColor,
                                     foreground=boxTextColor)
        self.ltdThreshold.grid(row=row,
                               column=1,
                               padx=PADX,
                               pady=PADY,
                               sticky=tk.EW)
        self.checkBoxes.append((self.ltdCB, self.tLtd))

        row += 1
        self.painiteCB = tk.Checkbutton(self.w,
                                        text='Track painite greater than',
                                        variable=self.tPainite,
                                        background=backgroundColor,
                                        foreground=textColor,
                                        command=self.onCheck)
        self.painiteCB.grid(row=row, padx=PADX, pady=PADY, sticky=tk.W)
        self.painiteThreshold = tk.Entry(self.w,
                                         background=boxColor,
                                         foreground=boxTextColor)
        self.painiteThreshold.grid(row=row,
                                   column=1,
                                   padx=PADX,
                                   pady=PADY,
                                   sticky=tk.EW)
        self.checkBoxes.append((self.painiteCB, self.tPainite))

        row += 1
        self.cargoB = tk.Checkbutton(self.w,
                                     text='Track my cargo',
                                     variable=self.cargo,
                                     background=backgroundColor,
                                     foreground=textColor,
                                     command=self.onCheck)
        self.cargoB.grid(row=row, column=0, padx=PADX, pady=PADY, sticky=tk.W)
        self.checkBoxes.append((self.cargoB, self.cargo))

        row += 1
        self.soundCB = tk.Checkbutton(
            self.w,
            text='Play a sound when threshold is met',
            variable=self.sound,
            background=backgroundColor,
            foreground=textColor,
            command=self.onCheck)
        self.soundCB.grid(row=row, column=0, padx=PADX, pady=PADY, sticky=tk.W)
        self.checkBoxes.append((self.soundCB, self.sound))

        row += 1
        self.overlayB = tk.Checkbutton(self.w,
                                       text='Show overlay',
                                       variable=self.overlay,
                                       background=backgroundColor,
                                       foreground=textColor,
                                       command=self.onCheck)
        self.overlayB.grid(row=row,
                           column=0,
                           padx=PADX,
                           pady=PADY,
                           sticky=tk.W)
        self.checkBoxes.append((self.overlayB, self.overlay))

        row += 1
        self.transB = tk.Checkbutton(self.w,
                                     text='Make overlay transparent',
                                     variable=self.trans,
                                     background=backgroundColor,
                                     foreground=textColor,
                                     command=self.onCheck)
        self.transB.grid(row=row, column=0, padx=PADX, pady=PADY, sticky=tk.W)
        self.checkBoxes.append((self.transB, self.trans))

        row += 1
        self.collectB = tk.Checkbutton(
            self.w,
            text=
            'Allow server to store prospecting event for statistical purpose (anonymous)',
            variable=self.collect,
            background=backgroundColor,
            foreground=textColor,
            command=self.onCheck)
        self.collectB.grid(row=row,
                           column=0,
                           padx=PADX,
                           pady=PADY,
                           sticky=tk.W)
        self.checkBoxes.append((self.collectB, self.collect))

        row += 1
        self.onlineDB = tk.Checkbutton(self.w,
                                       text='Start EliteProspecting online',
                                       variable=self.onlineD,
                                       background=backgroundColor,
                                       foreground=textColor,
                                       command=self.onCheck)
        self.onlineDB.grid(row=row,
                           column=0,
                           padx=PADX,
                           pady=PADY,
                           sticky=tk.W)
        self.checkBoxes.append((self.onlineDB, self.onlineD))

        row += 1
        self.settings = tk.Button(self.w,
                                  text="Save settings",
                                  command=self.saveSettings,
                                  background=backgroundColor,
                                  foreground=textColor)
        self.settings.grid(row=row, padx=PADX, pady=PADY, sticky=tk.W)

        row += 1
        self.onlineB = tk.Button(self.w,
                                 text="Go online",
                                 command=self.connect,
                                 background=backgroundColor,
                                 foreground=textColor)
        self.onlineLabel = tk.Label(self.w,
                                    text="Offline",
                                    background=backgroundColor)
        self.onlineB.grid(row=row, padx=PADX, pady=PADY, sticky=tk.W)
        self.onlineLabel.grid(row=row,
                              column=1,
                              padx=PADX,
                              pady=PADY,
                              sticky=tk.EW)
        self.onlineLabel.config(foreground="Red")

        self.loadConf()
        self.loadSetup()
        self.setupUi()
        self.onCheck()

        self.processThread = threading.Thread(target=self.processEvents)
        self.processThread.start()

        self.networkThread = threading.Thread(target=self.receiveMsg)
        self.networkThread.start()

        #go online at startup  ?
        if self.config.config['ui']['online'] == "1":
            self.connect()
Ejemplo n.º 27
0
 def initializeJournal(self):
     import journal
     renderer = journal.journal().device.renderer
     renderer.header = '<pre>' + renderer.header
     renderer.footer = renderer.footer + '</pre>'
     return
Ejemplo n.º 28
0
 def test_colorconsole(self):
     from journal.devices.ANSIColorConsole import ANSIColorConsole
     journal.journal().device = ANSIColorConsole()
     self.journal.log("Hello")
Ejemplo n.º 29
0
 def test_console(self):
     from journal.devices.Console import Console
     journal.journal().device = Console()
     self.journal.log("Hello")
Ejemplo n.º 30
0
 def record(self, entry):
     journal.journal().record(entry)
     return
Ejemplo n.º 31
0
#!/usr/bin/env python
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#                             Michael A.G. Aivazis
#                      California Institute of Technology
#                      (C) 1998-2005  All Rights Reserved
#
# <LicenseText>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#

import journal
print journal.journal().channels()

# version
__id__ = "$Id: channels.py,v 1.1.1.1 2005/03/08 16:13:53 aivazis Exp $"

# End of file 
Ejemplo n.º 32
0
 def record(self, entry):
     journal.journal().record(entry)
     return
Ejemplo n.º 33
0
 def initializeJournal(self):
     import journal
     renderer = journal.journal().device.renderer
     renderer.header = '<pre>' + renderer.header
     renderer.footer = renderer.footer + '</pre>'
     return
Ejemplo n.º 34
0
#!/usr/bin/env python
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#                             Michael A.G. Aivazis
#                      California Institute of Technology
#                      (C) 1998-2003  All Rights Reserved
#
# <LicenseText>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#

import journal
print journal.journal().channels()

# version
__id__ = "$Id: channels.py,v 1.1 2003/03/20 05:59:35 aivazis Exp $"

# Generated automatically by PythonMill on Wed Mar 19 19:26:18 2003

# End of file