示例#1
0
文件: Main.py 项目: guillemlla/MTPv2
def begin():
    #Setup the gpios, gets the mode and changes the leds based on the mode
    gpio.gpioSetup()
    mode = gpio.getMode()
    gpio.setLEDsMode(mode)

    #Waits until the button is pressed and afterwards set all the leds on
    gpio.buttonPressed(CTE.BTN_1)
    gpio.setLeds(True, True, True)

    #Based on the selected mode initialize one class or another, if it enters a
    #mode not declared it raises a ModeError Exception
    if mode == CTE.TX_MODE:
        tx = Tx.Tx()
        tx.sendData()
    elif mode == CTE.RX_MODE:
        rx = Rx.Rx()
        rx.receiveData()
    elif mode == CTE.NETWORK_MODE:
        main.startNetworkMode(USBManager.is_usb_connected())
    else:
        raise Exceptions.ModeError()

    #When finish set on the second led and all the others off
    gpio.setLeds(False, True, False)
示例#2
0
    def connect(self):
        self.disconnect = False
        self.old_total_receive_mess = 0

        with imaplib.IMAP4_SSL(self.imap_server) as imap:
            imap.login(self.user, self.__pass)
            while not self.disconnect:
                time.sleep(self.time)
                status, messages = imap.select("INBOX")
                self.total_receive_mess = int(messages[0])

                if self.old_total_receive_mess == self.total_receive_mess:
                    self.new_message = self.total_receive_mess - self.old_total_receive_mess
                    print(f'No new messages')

                elif self.old_total_receive_mess < self.total_receive_mess:
                    self.new_message = self.total_receive_mess - self.old_total_receive_mess
                    print(f'We have new mess: {self.new_message}')

                # print(f'Total Receive Message: {self.total_receive_mess}')
                self.old_total_receive_mess = self.total_receive_mess

                for i in range(self.total_receive_mess, self.total_receive_mess-self.new_message, -1):
                    if i<=0:
                        continue

                    res, msg = imap.fetch(str(i), "(RFC822)")

                    self.list_msg.append(Rx.Rxmsg())

                    for response in msg:
                        if isinstance(response, tuple):
                            # parse a bytes email into a message object
                            msg = email.message_from_bytes(response[1])
                            # subject = decode_header(msg["Subject"])[0][0]
                            '''if isinstance(subject, bytes):
                                # if it's a bytes, decode to str
                                print('subject in bytes')
                                subject = subject.decode()'''
                            # from_ = msg.get("From")
                            # self.list_msg[-1].readsubject(subject)

                            if msg.is_multipart():

                                for part in msg.walk():
                                    # extract content type of email
                                    # print(f'part: {part}') # print everything of the received mail
                                    content_type = part.get_content_type()
                                    content_disposition = str(part.get("Content-Disposition"))
                                    try:
                                        # get the email body
                                        body = part.get_payload(decode=True).decode()
                                    except:
                                        pass

                                    if content_type == "text/plain" and "attachment" not in content_disposition:
                                        # print text/plain emails and skip attachments

                                        self.list_msg[-1].readbody(body)
示例#3
0
 def __init__(self, show_init, wav_prefix, framerate, rx_sensitivity):
     sh_init = show_init or False
     frate = framerate or 44100
     rx_sens = rx_sensitivity or 0.11
     sample_width = 2
     channels = 1
     self.rx = Rx.Rx(sample_width, channels, frate, sh_init,
                     _rx_file(wav_prefix), rx_sens)
     self.tx = Tx.Tx(sample_width, channels, frate, sh_init,
                     _tx_file(wav_prefix))
示例#4
0
文件: rx-test.py 项目: gildasch/Rx
from TAP.Simple import *
import Rx
import json
import re

plan(None)

rx = Rx.Factory({"register_core_types": True})

isa_ok(rx, Rx.Factory)

index = json.loads(file('spec/index.json').read())

test_data = {}
test_schemata = {}


def normalize(entries, test_data):
    if entries == '*':
        entries = {"*": None}

    if type(entries) is type([]):
        new_entries = {}
        for n in entries:
            new_entries[n] = None
        entries = new_entries

    if len(entries) == 1 and entries.has_key('*'):
        value = entries["*"]
        entries = {}
        for k in test_data.keys():
示例#5
0
source_path = Path(__file__).resolve().parent
template_path = source_path / 'web-template'
env = Environment(loader=FileSystemLoader(str(template_path)),
                  trim_blocks=True,
                  lstrip_blocks=True)
env.filters['quote'] = escape

# Get jinja templates
file_template = env.get_template("file.html")
directory_template = env.get_template("directory.html")

### Get Rx Schema for The Configuration File ---------------------------------

config_schema_file = source_path / 'config-schema.yml'
config_schema = yaml.load(config_schema_file.open())
config_schema = Rx.make_schema(config_schema)

### Parse Command Line Arguments ---------------------------------------------

parser = argparse.ArgumentParser(
    description="check code style of a project based upon settings in " +
    ".style.yml")
parser.add_argument('web_directory',
                    help="directory in which to write web report")
parser.add_argument('--project_directory',
                    help="directory in which to place your project " +
                    "and .style.yml")

args = parser.parse_args()

web_directory = Path(args.web_directory)