예제 #1
0
    def __init__(self, **kwargs):
        global fromAppBuilt

        if not fromAppBuilt:
            return

        super(CryptoPricerGUI, self).__init__(**kwargs)
        self.dropDownMenu = CustomDropDown(owner=self)

        if os.name == 'posix':
            configPath = '/sdcard/cryptopricer.ini'
        else:
            configPath = 'c:\\temp\\cryptopricer.ini'
            self.toggleAppSizeButton.text = 'Half'  # correct on Windows version !

        self.configMgr = ConfigurationManager(configPath)
        self.controller = Controller(GuiOutputFormater(self.configMgr, activateClipboard=True), self.configMgr)
        self.dataPath = self.configMgr.dataPath
        self.histoListItemHeight = int(self.configMgr.histoListItemHeight)
        self.histoListMaxVisibleItems = int(self.configMgr.histoListVisibleSize)
        self.maxHistoListHeight = self.histoListMaxVisibleItems * self.histoListItemHeight

        self.appSize = self.configMgr.appSize
        self.defaultAppPosAndSize = self.configMgr.appSize
        self.appSizeHalfProportion = float(self.configMgr.appSizeHalfProportion)
        self.applyAppPosAndSize()

        # loading the load at start history file if defined
        pathFilename = self.configMgr.loadAtStartPathFilename

        if pathFilename != '':
            self.loadPathFilename(pathFilename)
예제 #2
0
    def setUp(self):
        if os.name == 'posix':
            FILE_PATH = '/sdcard/cryptopricer.ini'
        else:
            FILE_PATH = 'c:\\temp\\cryptopricer.ini'

        self.configMgr = ConfigurationManager(FILE_PATH)
        self.priceRequester = PriceRequester()
예제 #3
0
    def setUp(self):
        if os.name == 'posix':
            FILE_PATH = '/sdcard/cryptopricer.ini'
        else:
            FILE_PATH = 'c:\\temp\\cryptopricer.ini'

        configMgr = ConfigurationManager(FILE_PATH)
        self.printer = GuiOutputFormater(configMgr)
예제 #4
0
    def setUp(self):
        if os.name == 'posix':
            FILE_PATH = '/sdcard/cryptopricer.ini'
        else:
            FILE_PATH = 'c:\\temp\\cryptopricer.ini'

        self.configMgr = ConfigurationManager(FILE_PATH)
        self.priceRequester = PriceRequester()
        self.crypCompExchanges = CrypCompExchanges()
        self.processor = Processor(self.configMgr, self.priceRequester,
                                   self.crypCompExchanges)
예제 #5
0
def main():
    '''
	Maincl means main command line !
	Command line main which instanciate a Controller which uses a ConsoleOutputFormatter
	instead of a GuiOutputFormatter, what maingui does !
	'''
    if os.name == 'posix':
        configPath = '/sdcard/cryptopricer.ini'
    else:
        configPath = 'c:\\temp\\cryptopricer.ini'

    configMgr = ConfigurationManager(configPath)
    controller = Controller(ConsoleOutputFormatter(configMgr), configMgr,
                            PriceRequester())

    controller.commandLineLoop()
    def testConfigurationManagerInstanciation(self):
        self.configMgr = ConfigurationManager(self.filePath)
        self.assertEqual(self.configMgr.localTimeZone, 'Europe/Zurich')
        self.assertEqual(self.configMgr.dateTimeFormat, 'DD/MM/YY HH:mm')
        self.assertEqual(self.configMgr.dateOnlyFormat, 'DD/MM/YY')

        if os.name == 'posix':
            self.assertEqual(self.configMgr.dataPath,
                             '/sdcard/CryptoPricerData')
            self.assertEqual(self.configMgr.appSize, 'Half')
            self.assertEqual(self.configMgr.histoListItemHeight, '90')
        else:
            self.assertEqual(self.configMgr.dataPath, 'c:\\temp')
            self.assertEqual(self.configMgr.appSize, 'Full')
            self.assertEqual(self.configMgr.histoListItemHeight, '35')

        self.assertEqual(self.configMgr.loadAtStartPathFilename, '')
        self.assertEqual(self.configMgr.histoListVisibleSize, '3')
        self.assertEqual(self.configMgr.appSizeHalfProportion, '0.62')
        self.assertEqual(self.configMgr.referenceCurrency, 'USD')
    def testWithSlash(self):
        from configurationmanager import ConfigurationManager
        from guioutputformater import GuiOutputFormater
        from controller import Controller
        import os

        SeqDiagBuilder.activate('Controller', 'getPrintableResultForInput')  # activate sequence diagram building

        if os.name == 'posix':
            FILE_PATH = '/sdcard/cryptopricer.ini'
        else:
            FILE_PATH = 'c:\\temp\\cryptopricer.ini'

        configMgr = ConfigurationManager(FILE_PATH)
        controller = Controller(GuiOutputFormater(configMgr), configMgr)

        inputStr = 'mcap btc 0 all'
        _, _, _, _ = controller.getPrintableResultForInput(
            inputStr)

        SeqDiagBuilder.createDiagram('c:/temp', 'GUI', None, 20)
    def testConfigurationManagerInstanciationOneMissingKey(self):
        #removing second line in config file
        with open(self.filePath, 'r') as configFile:
            lines = configFile.readlines()

        with open(self.filePath, 'w') as configFile:
            # first line contains [General] section name !
            configFile.write(''.join(lines[0:1] + lines[2:]))

        self.configMgr = ConfigurationManager(self.filePath)
        self.assertEqual(self.configMgr.localTimeZone, 'Europe/Zurich')
        self.assertEqual(self.configMgr.dateTimeFormat, 'DD/MM/YY HH:mm')
        self.assertEqual(self.configMgr.dateOnlyFormat, 'DD/MM/YY')

        if os.name == 'posix':
            self.assertEqual(self.configMgr.dataPath,
                             '/sdcard/CryptoPricerData')
        else:
            self.assertEqual(self.configMgr.dataPath, 'c:\\temp')

        self.assertEqual(self.configMgr.loadAtStartPathFilename, '')
        self.assertEqual(self.configMgr.histoListVisibleSize, '3')
        self.assertEqual(self.configMgr.appSizeHalfProportion, '0.62')
        self.assertEqual(self.configMgr.referenceCurrency, 'USD')
예제 #9
0
        self.parsedParmData[self.MINUTE] = str(localNow.minute)


if __name__ == '__main__':
    from configurationmanager import ConfigurationManager
    from pricerequester import PriceRequester
    from crypcompexchanges import CrypCompExchanges
    from processor import Processor
    import os

    if os.name == 'posix':
        FILE_PATH = '/sdcard/cryptopricer.ini'
    else:
        FILE_PATH = 'c:\\temp\\cryptopricer.ini'

    cm = ConfigurationManager(FILE_PATH)
    pr = PriceRequester()
    cryp = CrypCompExchanges()
    proc = Processor(cm, pr, cryp)

    cpr = CommandPrice(proc, cm)

    print('HISTORICAL')

    cpr.parsedParmData[cpr.CRYPTO] = 'btc'
    cpr.parsedParmData[cpr.FIAT] = 'usd'
    cpr.parsedParmData[cpr.EXCHANGE] = 'bittrex'
    cpr.parsedParmData[cpr.DAY] = '12'
    cpr.parsedParmData[cpr.MONTH] = '9'
    cpr.parsedParmData[cpr.YEAR] = '2017'
    cpr.parsedParmData[cpr.HOUR] = '10'
예제 #10
0
                COMMAND_ERROR_TYPE_KEY] = self.commandError.COMMAND_ERROR_TYPE_INVALID_COMMAND
            self.commandError.parsedParmData[
                self.commandError.
                COMMAND_ERROR_MSG_KEY] = self.commandError.FIAT_LIST_MISSING_MSG

            return self.commandError, fiatDataList, flag
        else:
            return cryptoDataList, fiatDataList, flag


if __name__ == '__main__':
    from configurationmanager import ConfigurationManager
    import os

    filePath = None

    if os.name == 'posix':
        filePath = '/sdcard/cryptopricer_test.ini'
    else:
        filePath = 'c:\\temp\\cryptopricer_test.ini'

    r = Requester(ConfigurationManager(filePath))

    r.commandPrice = CommandPrice()
    inputStr = "btc usd Kraken 10/9/17 12:45"
    #    groupL = r._parseGroups(r.PATTERN_FULL_PRICE_REQUEST_WITH_OPTIONAL_COMMAND_DATA, inputStr)

    #    print(groupL)
    #    print(r._validateFullCommandPriceParsedGroupsOrder(groupL))
    print(r.getCommand(inputStr))