示例#1
0
文件: main.py 项目: Isi97/CSCB024
def initialize():
    app = wx.App()
    frame = MainWindow()

    # Assigning values to the commands module which are needclsed to interract with the GUI
    commands.initialize(frame=frame, code=config['SETTINGS']['weathercode'])

    frame.loadCommands()
    frame.output("Finished loading.")
    frame.output("Type 'help' for a list of commands.")

    app.MainLoop()
示例#2
0
def toplevel():
    # configure syslog
    syslog.openlog(ident="blue-raven", logoption=syslog.LOG_PID)
    syslog.syslog(syslog.LOG_INFO, 'starting up')

    # Allocate an element that broadcasts raw Rainforest packets
    usb = usbio.USBIO()
    
    # Allocate an element that collects bits of XML until a complete XML
    # fragment (<tag>...</tag>) has been assembled.  Then broadcast the
    # fragment as a single message to its listeners.
    rfc = raven_fragment_collector.RavenFragmentCollector()
    
    # Wrap the XML fragments in a format understood by the weMonitor API
    wmf = we_monitor_formatter.WeMonitorFormatter()
    
    # Allocate an element that POSTs XML fragments to the weMonitor 
    # Rainforest API
    wmw = we_monitor_writer.WeMonitorWriter()
    
    # For debugging, allocate an element that simply echos its input
    # to stdout.
    # ech = echo.Echo()
    
    # String the elements together and start the reader thread.
    usb.attach(rfc).attach(wmf).attach(wmw) # .attach(ech)

    # If you prefer to see the raw XML as it arrives from the USB
    # device. comment out the above line and uncomment this line.
    # usb.attach(rfc).attach(ech).attach(wmf).attach(wmw)

    # Sending an 'initialize' message causes the RAVEn to synchronize its
    # XML output -- without that, it sends an arbitrary number of partial
    # packets and lots of nulls.  (The initialize message also elicits an
    # "Unknown command" response, but that appears to be benign.)
    usb.update(commands.initialize())
    
    # Start the reader thread
    syslog.syslog(syslog.LOG_INFO, 'launching reader thread')
    usb.start()
    # Send a GET_DEVICE_INFO message to get a DeviceInfo response.
    time.sleep(1)
    usb.update(commands.get_device_info())
    
    # Should never get here...
    usb.thread.join()
示例#3
0
# encoding: utf-8

VERSION = (0, 0, 1)

from core import loader, parser, templates, package, utils
import commands

# patch the `import` statement so it can handle literate python
loader.patch()

if __name__ == '__main__':
    commands.initialize()
示例#4
0
    elif isinstance(obj, ss.HistoryCandlePacket):
        print(f"board: {obj.board}, seccode: {obj.seccode},\
                period: {obj.period}")
        ticks = []
        for i in obj.items:
            ticks.append([i.date, i.open, i.high, i.low, i.close])
        print(tabulate(ticks,
                       headers=['date', 'open', 'high', 'low', 'close']))
    else:
        # а все остальное на всякий случай печатаем
        print(f"CALLBACK {type(obj)}>\n{obj}")


if __name__ == '__main__':
    try:
        cmd.initialize("Logs", 3, custom_callback)
        login = os.environ['TRANSAQ_LOGIN']
        password = os.environ['TRANSAQ_PASS']
        cmd.connect(login, password, "tr1.finam.ru:3900")
        # Тут должна быть асинхронная логика,
        # но для примера просто ждем ответ сервера
        # Если не успевает произойти соединение - увеличьте время
        time.sleep(20)
        cmd.get_history('TQBR', 'GAZP', 2, count=10)
        # Тут должна быть асинхронная логика,
        # но для примера просто ждем ответ сервера
        time.sleep(10)
    except Exception as exc:
        print(f"EXCEPTION:{exc}")
    finally:
        print(cmd.disconnect())
示例#5
0
# encoding: utf-8

VERSION = (0, 0, 1)

from core import loader, parser, templates, package, utils
import commands

# patch the `import` statement so it can handle literate python
loader.patch()

if __name__ == "__main__":
    commands.initialize()
示例#6
0
print("writing XML output to " + sys.argv[1])

# Allocate an element that collects bits of XML until a complete XML
# fragment (<tag>...</tag>) has been assembled.  Then broadcast the
# fragment as a single message to its listeners.
fw = file_writer.FileWriter(sys.argv[1])

# For debugging, allocate an element that simply echos its input
# to stdout.
ech = echo.Echo()

# String the elements together and start the reader thread.
usb.attach(fw).attach(ech)

# Sending an 'initialize' message causes the RAVEn to synchronize its
# XML output -- without that, it sends an arbitrary number of partial
# packets and lots of nulls.  (The initialize message also elicits an
# "Unknown command" response, but that appears to be benign.)
usb.update(commands.initialize())

# Start the reader thread
usb.start()

# Send a GET_DEVICE_INFO message to get a DeviceInfo response.
time.sleep(1)
usb.update(commands.get_device_info())

# Should never get here...
usb.thread.join()