コード例 #1
0
class TestConfig(TestCase):
    def setUp(self):
        self.conf = Config(configpath='../data/config.json')
        self.conf.getconfig()

    def evalcolor(self):
        color = self.conf.Color
        r = color[0]
        g = color[1]
        b = color[2]
        if (r not in range(0, 2)) | (g not in range(0, 2)) | (b not in range(
                0, 2)):
            return False
        else:
            return True

    def test_getconfig(self):

        self.assertIsInstance(self.conf.LCDPin1, int,
                              'Config LCDPin1 is not an Integer!!')
        self.assertIn(self.conf.LCDPin1, range(0, 4),
                      'Config LCDPin1 is not in I2C Range!!')
        self.assertIsInstance(self.conf.LCDPin2, int,
                              'Config LCDPin2 is not an Integer!!')
        self.assertIn(self.conf.LCDPin2, range(0, 4),
                      'Config LCDPin1 is not in I2C Range!!')
        self.assertIsInstance(self.conf.RelayPin, int,
                              'Config RelayPin is not an Integer!!')
        self.assertIn(self.conf.RelayPin, range(0, 27),
                      'Config LCDPin1 is not in GPIO Range!!')
        self.assertIsInstance(self.conf.MotionDetPin, int,
                              'Config MotionDetPin is not an Integer!!')
        self.assertIn(self.conf.MotionDetPin, range(0, 27),
                      'Config LCDPin1 is not in GPIO Range!!')
        self.assertIsInstance(self.conf.WPM, int,
                              'Config WPM is not an Integer!!')
        self.assertGreaterEqual(self.conf.WPM, 1,
                                'Config WPM is not Greater than 1!!')
        self.assertIsInstance(self.conf.MaxWPM, int,
                              'Config MaxWPM is not an Integer!!')
        self.assertGreaterEqual(
            self.conf.MaxWPM, self.conf.WPM,
            'Config MaxWPM is not Greater or Equal to WPM!!')
        self.assertLess(
            self.conf.MaxWPM, 31,
            'Config MaxWPM is Greater than 30WPM -- Seriously? !!')
        self.assertIsInstance(self.conf.SpeedAdjust, bool,
                              'Config SpeedAdjust is not Boolean!!')
        self.assertIsInstance(self.conf._Colorstr, str,
                              'Config Stored Color String is not a String!!')
        self.assertTrue(
            self.evalcolor(),
            'Parsed Color is not valid - value of number is not (0 or 1) and in form (#, #, #)'
        )
        self.assertIsInstance(self.conf.ParagraphSep, str,
                              'Config ParagraphSep is not a String!!')
コード例 #2
0
class TestRelay(TestCase):
    def setUp(self):
        p = os.path.dirname(os.getcwd())
        p = os.path.join(p, 'CERMMorse')
        p = os.path.join(p, 'data')
        p = os.path.join(p, 'config.json')
        os.path.normpath(p)
        self.config = Config(configpath=p)
        self.config.getconfig()
        self.relay = Relay(self.config)

    def test_fire(self):
        self.relay.fire(1)

    def test_pause(self):
        self.relay.pause(.25)

    def test_both(self):
        self.test_fire()
        self.test_pause()
        self.test_fire()
        self.test_pause()
        self.test_fire()
コード例 #3
0
#

import os
from requests.auth import HTTPBasicAuth
import json
import sys
from readconfig import Config

if len(sys.argv) < 2:
    print("An hostname must be supplied.", file=sys.stderr)
    sys.exit(1)

hostname = sys.argv[1]

config = Config()
conf = config.getconfig()

config.load_ca()

import requests

baseurl = conf['main']['url']
uuid_path = "/.uuid_centralized"

organization_uuid = conf['main']['organization_uuid']
uuid = ""

if not os.path.exists(uuid_path):
    with open(uuid_path, 'w') as u:
        with open('/proc/sys/kernel/random/uuid', 'r') as procfile:
            uuid = procfile.read().replace('\n', '')
コード例 #4
0
                md.pause(self.wordgap)
            elif element == '.':
                md.fire(self.dot)
                md.pause(self.gap)
            elif element == '-':
                md.fire(self.dash)
                md.pause(self.gap)
            elif element == 'X':
                md.fire(self.zerodash)
                md.pause(self.gap)
            elif element == 'L':
                md.fire(self.longdash)
                md.pause(self.gap)
            elif element == 'G':
                md.pause(self.lettergap)


if __name__ == '__main__':
    import os

    p = os.path.dirname(os.getcwd())
    p = os.path.join(p, 'CERMMorse')
    p = os.path.join(p, 'data')
    p = os.path.join(p, 'config.json')
    os.path.normpath(p)
    cnf = Config(configpath=p)
    cnf.getconfig()
    pm = PlayMorse(5, cnf)
    print(pm)
    pm.playchar("Test Message. And another Test message. , /")