Exemplo n.º 1
0
    def test_header_render(self):

        h1 = Header("test", 1)
        self.assertEqual(h1.render(), "<h1> test </h1>")
        h1 = Header("hello", 2)
        self.assertEqual(h1.render(), "<h2> hello </h2>")
        h1 = Header(("hello world"), 3)
        self.assertEqual(h1.render(), "<h3> hello world </h3>")
Exemplo n.º 2
0
 def _write_headers(self, msg):
     for h, v in msg.items():
         print >> self._fp, '%s:' % h,
         if self.__maxheaderlen == 0:
             # Explicit no-wrapping
             print >> self._fp, v
         elif isinstance(v, Header):
             # Header instances know what to do
             print >> self._fp, v.encode()
         elif _is8bitstring(v):
             # If we have raw 8bit data in a byte string, we have no idea
             # what the encoding is.  There is no safe way to split this
             # string.  If it's ascii-subset, then we could do a normal
             # ascii split, but if it's multibyte then we could break the
             # string.  There's no way to know so the least harm seems to
             # be to not split the string and risk it being too long.
             print >> self._fp, v
         else:
             # Header's got lots of smarts, so use it.
             print >> self._fp, Header(v,
                                       maxlinelen=self.__maxheaderlen,
                                       header_name=h,
                                       continuation_ws='\t').encode()
     # A blank line always separates headers from body
     print >> self._fp
Exemplo n.º 3
0
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        self.setWindowTitle("Salary Manager")
        self.setGeometry(50,50, 900, 700)
        self.setWindowState(QtCore.Qt.WindowMaximized)

        self.setWindowIcon(QtGui.QIcon("Resources/rupee.png"))

        self.bgWidget = QtGui.QWidget()
        self.header = Header()
        self.header.setLogo("Resources/iiitk.png")
        self.header.setHeaderText("Salary Management System", "Indian Institute of Information Technology Kalyani")

        self.widgetStack = QtGui.QStackedWidget()
        self.setCentralWidget(self.bgWidget)
        self.setupUI()

        self.pages = {
            "Login": LoginWidget,
            "Home": HomeWidget,
            "Add Employee": AddEmployeeWidget,
            "Del Employee": DelEmployeeWidget,
            "Edit Employee": EditEmployeeWidget,
            "Show Employee": ShowEmployeeWidget,
            "Add Designation": AddDesignationWidget,
            "Edit Designation": EditDesignationWidget,
            "Show Designation": ShowDesigationWidget,
            "Calc Salary": CalculateSalaryWidget,
            "Result": ShowPaySlipWidget
        }

        self.gotoPage("Login")
Exemplo n.º 4
0
  def main(self):
    header = Header()

    header.setDividerLength(60)
    header.setValueColumn(20)
    header.setUserID("ADET_ID")
    header.setProgrammer("Lname, Fname MI.")
    header.setCourse("CSCI-400")
    header.setTerm("SP14")
    header.setProject("01")
    header.setPython("3.3.3")

    print("******************************************")
    print("*** Header Format Examples ***")
    print("******************************************")
    print('')

    for ext in ["hack","xml","hdl","asm","vm","jack","py"]:
      print("---------------")
      print(ext.upper())
      print("---------------")
      print(header.gen("AnExample." + ext))

    print("******************************************")
    print("*** End of Header Format Examples ***")
    print("******************************************")
Exemplo n.º 5
0
    def __init__(self):

        self.header = Header()
        self.fdata = Data()
        self.fdict = Dict()

        self.__fd = None
Exemplo n.º 6
0
    def read_db(self, file_path):
        print("read_db")
        print(file_path)

        #--- open file
        with open(file_path, "rb") as fd:

            #--- header
            bheader = fd.read(Header.SIZE)
            header = Header(bheader)
            print(header)

            #--- dict
            bdict = fd.read(header.dict_size)
            fdict = Dict(bdict)
            # for r in fdict.records_map.values():
            # 	print(r)
            # print(fdict)

            #--- data
            bdata = fd.read(header.data_size)
            fdata = Data(bdata)

            print()
            print("root files: ")
            for r in fdict.records_map.values():
                if r.pid == 0:
                    ff = fdata.get_record(r.daddr, r.dsize)
                    print(ff)
def parseMessage(message):
    #if server message is an empty msg with no header - total timeout
    if len(message) == 0:
        return 0, 0, 0, 0
    #otherwise handle the file as normal
    else:
        hdr = Header()
        hdr.Write()
        print "msg"
        print message
        headerData = message[:39]
        print repr(headerData)
        headerdict = hdr.Read(headerData)

        #splitMessage = message.split("@")
        messageType = headerdict["datatype"]
        data = message[40:]
        index = headerdict["sequencenumber"]
        fileName = headerdict["options"]
        #index:message populate file dict
        #if data exists its part of the file and should be stored
        if len(data) != 0:
            fileDict[index] = data

        return data, index, fileName, messageType
Exemplo n.º 8
0
    def read_db(self, file_path):
        print("read_db")
        print(file_path)

        #--- open file
        with open(file_path, "rb") as fd:

            #--- header
            bheader = fd.read(Header.SIZE)
            header = Header(bheader)
            print(header)

            #--- dict
            fd.seek(header.dict_start)
            bdict = fd.read(header.dict_size)
            fdict = Dict(bdict)
            # for r in fdict.records_map.values():
            # 	print(r)

            #--- data
            # for r in fdict.records_map.values():
            # 	if r.pid == 0:
            # 		# print(r.fid, r.pid)
            # 		start = r.daddr
            # 		size = r.dsize
            # 		fd.seek(start)
            # 		bfile_data = fd.read(size)
            # 		record = DataRecord(bfile_data)
            # 		print(record)

            Store.reprint(fd, fdict, 0, 0)
Exemplo n.º 9
0
    def make_db(self, scan_path, out_file):
        print("make_db")
        print(scan_path)
        print(out_file)

        header = Header()
        fdict = Dict()
        fdata = Data()

        self.__start_scan(scan_path, fdata)

        print(len(fdata.records))

        #--- make dict
        for record in fdata.records:
            fdict.append_record(record.fid, record.pid)

        print(len(fdict.records_map))

        #--- update header data
        header.dict_start = Header.SIZE
        header.dict_size = fdict.get_bdata_size()

        header.data_start = Header.SIZE + header.dict_size

        # fdata_bin = fdata.pack()
        # header.data_size = len(fdata_bin)

        #---
        fdata_bin = b""
        # fdata_start = header.data_start
        fdata_start = 0
        for record in fdata.records:
            rb = record.pack()

            #--- update dict addr
            fdict.set_addr(record.fid, fdata_start, len(rb))

            fdata_bin += rb
            fdata_start += len(rb)

        header.data_size = len(fdata_bin)

        # flat: 1496, gzip: 8182
        # gzip_fdata_bin = gzip.compress(fdata_bin,9)

        # print("-"*80)
        # print("flat: {:>4}, gzip: {:>4}".format(len(gzip_fdata_bin), len(fdata_bin)))
        # print("-"*80)

        #--- make binary
        bdata = b""
        bdata += header.pack()
        bdata += fdict.pack()
        bdata += fdata_bin

        #--- write file
        with open(out_file, "wb") as fd:
            fd.write(bdata)
Exemplo n.º 10
0
 def __init__(self, urlBase, name, token):
     self.name = name
     self.token = token
     self.urlBase = urlBase
     self.auth = Auth(self.token)
     self.header = [
         Header("Content-Type", "Content-Type", "application/json", "text")
     ]
Exemplo n.º 11
0
def process(url):
    header = Header(url)
    header.reader()
    print("Scanning: " + color.blue + url + color.end)
    if header.status:
        scanObj = Scan(url)
        scanObj._start()
    else:
        print(color.blue + url + color.red + " is Unreachable")
    sleep(3)
Exemplo n.º 12
0
    def create(self, db_path: str, db_name: str):

        full_path = os.path.join(db_path, db_name)
        if not os.path.exists(full_path):
            os.mkdir(full_path)

        header = Header(full_path)
        header.save()

        self.__db_path = full_path
def sendAck(index, fileName):
    ack = Header()
    #populate it with the sequencenum and file name and ACK message type
    ack.datatype = "ACK"
    ack.sequencenumber = index
    ack.options = fileName
    ackHead = ack.Write()

    #send just the ACK header
    clientSocket.sendto(ackHead, serverAddr)
Exemplo n.º 14
0
Arquivo: ROM.py Projeto: ch3rag/NESPY
 def __init__(self, rom_path: str):
     with open(rom_path, "rb") as file:
         self.rom = file.read()
     self.header = Header(self.rom[0:15])
     self.trainer_data = []
     if self.header.trainer:
         self.trainer_data = self.rom[16:16 + 512]
         self.prg_data = self.rom[16 + 512:16 + 512 +
                                  self.header.prg_data_size]
     else:
         self.prg_data = self.rom[16:16 + self.header.prg_data_size]
Exemplo n.º 15
0
 def __init__(self, rfc, contrasena):
     self.__rfc = rfc
     self.__contrasena = contrasena
     self.__sesion = requests.Session()
     self.__directorioAGuardar = ''
     self.__header = Header()
     self.__hostCfdiau = 'cfdiau.sat.gob.mx'
     self.__hostPortalCfdi = 'portalcfdi.facturaelectronica.sat.gob.mx'
     self.__urlCfdiau = 'https://' + self.__hostCfdiau + '/'
     self.__urlPortalCfdi = 'https://' + self.__hostPortalCfdi + '/'
     self.__urlCfdiCont = 'https://cfdicontribuyentes.accesscontrol.windows.net/'
     self.__error = ''
     self.__listaDocumentos = []
Exemplo n.º 16
0
    def __init__(self, file_path):
        self.file_path = file_path

        fd = gzip.open(file_path, "rb")

        bheader = fd.read(Header.SIZE)
        self.header = Header(bheader)

        fd.seek(self.header.data_start)
        bin_data = fd.read(self.header.data_size)

        self.fdata = Data(bin_data)
        fd.close()
Exemplo n.º 17
0
    def readFileHeader(self, inFile):
        """
        Read the header of the open file
        """
        for line_counter in range(constants.HEADER_LINES):
            line_read = inFile.readline()
            if (line_counter == constants.HEADER_DATE):
                date = line_read
            elif (line_counter == constants.HEADER_HOURS):
                time = line_read
            elif (line_counter == constants.HEADER_FILETYPE):
                scope = line_read

        return Header(date, time, scope)
Exemplo n.º 18
0
def miner(transaction_pool):
    last_block_header = '0'*64 # genesis header
    last_block_target = '%064x' % (0x7ffff * 2 ** (8 * (0x20 - 3)))
    #uncomment the line below for harder difficulty
    #last_block_target = '000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
    # init the block chains
    block_chain = BlockChain()
    block = Block(Header(last_block_header), last_block_target)
    # use variable to keep track of where in the pool we left off reading from
    # so that we're not going to re-mine the same block
    left_off_in_pool = 0
    # add coinbase transaction
    block.add_transaction(CoinbaseTransaction(0))
    for i in range(1, 9):
        block.add_transaction(transaction_pool.transactions[i])
        left_off_in_pool = i
    # now that our block is full, we can start to mine it.
    while not block.mine_this_block():
        continue
    block_chain.add_block(block)
    print("current blockchain height ", block_chain.size_of_chain())
    sleep(5)
    # our new header for block 2 will need the hash of block 1
    last_block_header = double_hash(encode_and_concenate([block_chain.latest_block().BlockHash]))
    block_2 = Block(Header(last_block_header), last_block_target)
    block_2.add_transaction(CoinbaseTransaction(block.transactions[0].current_total))
    for i in range(left_off_in_pool+9):
        block_2.add_transaction(transaction_pool.transactions[i])
        left_off_in_pool = i
    # now that our block is full, we can start to mine it.
    while not block_2.mine_this_block():
        continue
    block_chain.add_block(block_2)
    print("current blockchain height ", block_chain.size_of_chain())
    print()
    for i, block_added in enumerate(block_chain.blocks):
        print('Block #{} was added. It took {} steps to find it.'.format(i, block_added.nonce))
Exemplo n.º 19
0
def inputs():
    #define global variables
    global state
    global putFile
    #create header to populate request message with
    while(1):
        #sys arg input scheme
        datatype = sys.argv[1]
        #original input scheme
        #datatype = raw_input("GET or PUT a file?\n")
        if (datatype == "GET") or (datatype == "PUT"):
            break
        else:
            print "Please input a proper request (GET or PUT)"
    while(1):
		#sysarg input
		filename = sys.argv[2]	
		#original input method
		#filename = raw_input("What file do you want/have?\n")
		if datatype == "PUT":
			if os.path.isfile(filename):
				print "Fetching File..."
				putFile = filename
				
				break
			else:
				print "File does not exist. Choose another file..."
		if datatype == "GET":
			break
    print"Processing Request..."

    #create instance of header class
    request = Header()
    #populate it with the input and write a header for the request
    request.datatype = datatype
    request.options = filename
    reqHead = request.Write()
    #update state variable
    if request.datatype == "GET":
        state=1
    else:
        state=2
    #return the header meant to be sent with the request
    return state, reqHead
Exemplo n.º 20
0
def main():
	
	file_name = verificador(sys.argv)
	
	nomeArqFinal = file_name
	nomeArqFinal = nomeArqFinal.replace('.s', '.m')
	print(nomeArqFinal)

	arq = open(file_name, 'r')

	codigoCompleto = arq.readlines()
	#codigoCompleto.remove('\n')

	final = open(nomeArqFinal, 'w')
	
	header = Header()
	listaText = []
	qntInstrucoes(header, codigoCompleto, listaText)

	content = []

	# HEADER

	content.append("f0f0 f0f0 ")
	content.append("0000 0000 ")
	content.append(hex(header.qntInstrucoes)[2:].zfill(4))
	content.append(' ')
	content.append("0000 ")
	content.append("f0f0 f0f0")
	final.write(''.join(content))

	# TEXT

	regs = Listas()
	for l in listaText:
		linhaAtual = []
		linhaAtual = l.split(' ')
		print(linhaAtual)

	arq.close()
	final.close()
Exemplo n.º 21
0
def readHeader(fileName):
    """
    Returns a tuple with the date, time, company and scope specified in input file.
    Requires: input file is a text file in established format and fileName is a string with the name of the file.
    Ensures: returnal of a tuple in format (date, time, company, scope).
    """

    inFile = open(fileName, "r")
    inFile.readline()
    time = inFile.readline().replace(
        "\n", "")  #removes leftover \n from ending of lines in text file
    inFile.readline()
    date = inFile.readline().replace("\n", "")
    inFile.readline()
    company = inFile.readline().replace("\n", "")
    scope = inFile.readline().replace("\n", "").replace(":", "")

    inFile.close()
    header = Header(date, time, company, scope)

    return header
Exemplo n.º 22
0
    def build(self):
        appLayout = FloatLayout(size=(800, 600))

        bg = Image(source='Images/Metal2.jpg', pos=(0, 0), size=(1500, 840))

        g1 = Gauge()
        g1s = ScatterLayout(scale=0.5, size=g1.size, pos=(30, 80))
        g1s.add_widget(g1)

        g2 = Gauge()
        g2s = ScatterLayout(scale=0.5, size=g1.size, pos=(200, 80))
        g2s.add_widget(g2)

        g3 = Gauge()
        g3s = ScatterLayout(scale=0.5, size=g1.size, pos=(300, 80))
        g3s.add_widget(g3)

        head = Header()
        headscat = Scatter(size=head.size, pos=(0, 530), do_translation=False)
        headscat.add_widget(head)

        foot = Footer()
        Footer.updatedate(foot)
        #Clock.schedule_interval(foot.updatetime, 1)
        Clock.schedule_interval(partial(Footer.updatetime, foot), 1)
        Clock.schedule_interval(partial(Footer.updatedate, foot), 3600)
        #footscat = Scatter(size=foot.size, pos=(0,-10), do_translation=False)
        #footscat.add_widget(foot)

        appLayout.add_widget(bg)
        appLayout.add_widget(g1s)
        appLayout.add_widget(g2s)
        appLayout.add_widget(g3s)
        appLayout.add_widget(headscat)
        appLayout.add_widget(foot)

        Window.size = (800, 600)
        return appLayout
Exemplo n.º 23
0
	def __init__(self, block_bytes_array, _block_num):
		bytes_magic = block_bytes_array[:4]
		bytes_rest = block_bytes_array[4:]

		bytes_size = bytes_rest[:4]
		bytes_rest = bytes_rest[4:]

		bytes_header = bytes_rest[:80]
		bytes_rest = bytes_rest[80:]

		bytes_tx_count = bytes_rest[:1] # get varInt prefix
		bytes_rest = bytes_rest[1:]

		# check if varInt is on 1, 2, 4, or 8 bytes
		if(bytes_tx_count[0] == 253): # varInt is on 2 bytes AFTER the prefix
			bytes_tx_count = bytes_rest[:2]
			bytes_rest = bytes_rest[2:]

		elif(bytes_tx_count[0] == 254): # varInt is on 4 bytes AFTER the prefix
			bytes_tx_count = bytes_rest[:4]
			bytes_rest = bytes_rest[4:]

		elif(bytes_tx_count[0] == 255): # varInt is on 8 bytes AFTER the prefix
			bytes_tx_count = bytes_rest[:8]
			bytes_rest = bytes_rest[8:]
		# else varInt was on 1 bytes, nothing to do
			

		bytes_tx_data = bytes_rest

		self.block_num = _block_num
		self.magic = int.from_bytes(bytes_magic, byteorder='little')
		self.size = int.from_bytes(bytes_size, byteorder='little')
		self.tx_count = int.from_bytes(bytes_tx_count, byteorder='little')
		self.header = Header(bytes_header)
		self.transactions = Transactions(bytes_tx_data, self.tx_count)
Exemplo n.º 24
0
 def __init__(self):
     super(Query, self).__init__(Header(MessageType.query))
Exemplo n.º 25
0
    def __init__(self):
        super().__init__()
        self.setWindowTitle('Petro-Explorer v1.0')
        win_icon = QIcon('icons/Logo.ico')
        self.setWindowIcon(win_icon)
        self.setStyleSheet('background-color: #363f49;')

        self.header = Header()
        self.navigation = Navigation()
        self.p_top_bar = PetrophysicsTopBar()
        self.s_top_bar = StatisticsTopBar()
        self.p_options_1 = PetrophysicsOptions(_mode='KCarman')
        self.p_options_2 = PetrophysicsOptions(_mode='TCoates')
        self.p_options_3 = PetrophysicsOptions(_mode='Winland')
        self.p_options_4 = PetrophysicsOptions(_mode='RQIFZI')
        self.p_options_5 = PetrophysicsOptions(_mode='Lucia')
        self.p_options_6 = PetrophysicsOptions(_mode='DParsons')
        self.s_options_1 = StatisticsOptions(_mode='Regression')
        self.s_options_2 = StatisticsOptions(_mode='Statistics')
        self.s_options_3 = StatisticsOptions(_mode='Histogram')
        self.s_options_4 = StatisticsOptions(_mode='Boxplot')
        self.sp_controls = SpreadsheetControls()
        self.plot_controls = PlotControls()
        self.plot_viewer = PlotViewer()
        self.spreadsheet = Spreadsheet()
        self.status_bar = QStatusBar()

        self.scroll_area_1 = QScrollArea()
        self.scroll_area_1.setWidget(self.spreadsheet)
        self.scroll_area_1.setWidgetResizable(True)

        self.scroll_area_2 = QScrollArea()
        self.scroll_area_2.setWidget(self.plot_viewer)
        self.scroll_area_2.setWidgetResizable(True)

        self.bar_widget = QWidget()
        self.bar_widget.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum)

        self.central_widget = QWidget()
        self.options_widget = QWidget()

        self.docking_options = QDockWidget()
        self.docking_options.setWidget(self.options_widget)
        self.docking_options.setTitleBarWidget(
            DockWidgetRibbon(' Opções de cálculo'))

        self.docking_options2 = QDockWidget()
        self.docking_options2.setWidget(self.sp_controls)
        self.docking_options2.setTitleBarWidget(
            DockWidgetRibbon(' Controles de visualização'))

        self.setCentralWidget(self.central_widget)
        self.setStatusBar(self.status_bar)
        self.addToolBar(self.navigation)
        self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea,
                           self.docking_options)
        self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea,
                           self.docking_options2)
        self.connections()
        self.buildLayout()

        self.centralWidget().setStyleSheet('background-color: #2e3843')
        self.spreadsheet.setStyleSheet('background-color: white')
        self.status_bar.setStyleSheet('color: white')
Exemplo n.º 26
0
    def __init__(self):
        Gtk.Window.__init__(self,
                            title="Network Traffic Based Software Generation")
        # screenWidth = Gdk.Screen.get_width(Gdk.Screen.get_default())
        # screenHeigth = Gdk.Screen.get_height(Gdk.Screen.get_default())
        # Gtk.Window.resize(self,screenWidth/10,screenHeigth/3)
        self.PCAPWidget = ""
        self.PacketList = {}
        self.ProtocolList = {}
        self.filterExpression = "le Filter"
        self.PacketAreaBox = PacketArea(self)
        mainGrid = Gtk.Grid()
        # mainGrid.set_column_spacing(4)
        # mainGrid.set_row_spacing(4)
        # mainGrid.set_row_homogeneous(False)
        # mainGrid.set_hexpand(False)
        self.add(mainGrid)
        #
        # for x in range(4):
        # mainGrid.set_row_baseline_position(x,Gtk.BaselinePosition.CENTER)

        #Start of Header
        HeaderBox = Header(self, "Network Traffic Based Software Generation")

        HeaderBox.addButton("State Machine")
        HeaderBox.addButton("Create Session")
        HeaderBox.addButton("Open Session")
        HeaderBox.addButton("Close Session")
        HeaderBox.addButton("Switch Workspace")
        HeaderBox.addButton("Open PCAP")
        HeaderBox.addButton("Terminal")
        HeaderBox.showButtons()

        HeaderButtons = HeaderBox._buttons

        HeaderButtons[6].connect("clicked", HeaderBox.Terminal_clicked)
        HeaderButtons[5].connect("clicked", HeaderBox.PCAP_clicked)
        HeaderButtons[4].connect("clicked", HeaderBox.Workspace_clicked)
        HeaderButtons[3].connect("clicked", HeaderBox.OpenSession_clicked)
        HeaderButtons[2].connect("clicked", HeaderBox.OpenSession_clicked)
        HeaderButtons[1].connect("clicked", HeaderBox.NewSession_clicked)
        HeaderButtons[0].connect("clicked", HeaderBox.StateMachine_clicked)

        mainGrid.attach(HeaderBox, 0, 0, 4, 1)
        #End of Header

        #Image Containing the status.
        StatusIndicator = Gtk.Image.new_from_file("statusIndicator.png")
        StatusFrame = Gtk.Frame()
        StatusBox = Gtk.Box(spacing=0)
        StatusBox.add(StatusFrame)
        mainGrid.attach(StatusBox, 0, 1, 4, 1)
        StatusBox.pack_start(StatusIndicator, False, True, 0)
        #End of Image containing the Status.

        #Start of Sessions View
        SessionsBox = Session()
        SessionsBox.addSession("Session A")
        SessionsBox.addSession("Session B")
        SessionsBox.addSession("Session C")
        SessionsBox.showSessions()
        SessionsBox.set_vexpand(True)
        mainGrid.attach(SessionsBox, 0, 2, 1, 1)
        #End of Sessions View

        #Start of PDML View
        # PDMLFrame = Gtk.Frame()
        PDMLBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
        PDMLLabel = Gtk.Label("PDML View")
        PDMLLabel.modify_bg(Gtk.StateType.NORMAL,
                            Gdk.color_parse("light blue"))
        PDMLBox.pack_start(PDMLLabel, False, False, 0)
        PDMLViewBox = PDMLView(self)
        PDMLBox.pack_start(PDMLViewBox, False, False, 0)

        PDMLBox.add(self.PacketAreaBox)
        PDMLBox.set_hexpand(True)
        # PDMLBox.pack_start(self.PacketAreaBox,True,True,0)

        mainGrid.attach(PDMLBox, 1, 2, 4, 1)
        #End of PDML View

        #Start of Tagging View
        TagBox = TagArea()
        TagBox.addCombobox("Saved Tag")
        TagBox.addField("Tag Name")
        TagBox.addField("Tagged Field")
        TagBox.addField("Tag Description")
        TagBox.populateFields()
        TagBox.showFields()

        TagBox.addButton("Update")
        TagBox.addButton("Cancel")
        TagBox.showButtons()

        mainGrid.attach(TagBox, 0, 3, 1, 1)
        #End of Tagging View

        #Start of field area View
        FieldAreaBox = FieldArea()
        mainGrid.attach(FieldAreaBox, 1, 3, 1, 1)

        FieldAreaBox.addField("icmp.type", "Type 8 [Echo ping request]", 1, 34,
                              "8", "8", 2)

        #Start of Message Type View
        MessageTypeBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                 spacing=0)
        mainGrid.attach(MessageTypeBox, 2, 3, 2, 1)

        MessageTypeFrame = Gtk.Frame()
        MessageTypeBox.add(MessageTypeFrame)
        #
        #
        #
        #IMPORTANT: Notebook requires all views to be inside a box. This section is all the views until I find a way to have it set up more efficiently.
        #
        #Start of New/Modify
        MessageTypeTabs = Gtk.Notebook()
        NewModifyView = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                spacing=0)
        InstructionsLabel = Gtk.Label(
            "To create a new message type, please enter a message type name and select message type field value pair(s). \n To Update/delete an existing message type, please select from the existing message type first \n and the previously selected name and field value pair(s) will be pre-populated."
        )
        InstructionsLabel.set_line_wrap(True)

        ExistingMessageTypeBox = Gtk.Box(spacing=1)
        ExistingMessageLabel = Gtk.Label("Existing Message Type")
        ExistingMessageTypeBox.pack_start(ExistingMessageLabel, False, False,
                                          0)
        ExistingMessageType = Gtk.Entry()
        ExistingMessageTypeBox.pack_start(ExistingMessageType, False, False, 0)

        MessageTypeNameBox = Gtk.Box(spacing=2)
        MessageTypeLabel = Gtk.Label("Message Type Name")
        MessageTypeNameBox.pack_start(MessageTypeLabel, False, False, 0)
        MessageTypeName = Gtk.Entry()
        MessageTypeNameBox.pack_start(MessageTypeName, False, False, 0)

        MessageTypePairsBox = Gtk.Box(spacing=2)
        MessageTypePairsLabel = Gtk.Label("Message Type Field\n Value Pair(s)")
        MessageTypePairsBox.pack_start(MessageTypePairsLabel, False, False, 0)
        ValuePairs = Gtk.Entry()
        MessageTypePairsBox.pack_start(ValuePairs, False, False, 0)

        NewModifyView.pack_start(InstructionsLabel, False, False, 0)
        NewModifyView.pack_start(ExistingMessageTypeBox, False, False, 0)
        NewModifyView.pack_start(MessageTypeNameBox, False, False, 0)
        NewModifyView.pack_start(MessageTypePairsBox, False, False, 0)

        SelectBothField = Gtk.CheckButton(
            label="Select both field name and value")
        SelectFieldNameOnly = Gtk.CheckButton(label="Select field name only")

        NewModifyView.pack_start(SelectBothField, False, False, 0)
        NewModifyView.pack_start(SelectFieldNameOnly, False, False, 0)

        OperationButtons = Gtk.Box(spacing=2)
        SaveButtonMessageType = Gtk.Button(label="Save")
        DeleteButtonMessageType = Gtk.Button(label="Delete")
        ClearButtonMessageType = Gtk.Button(label="Clear")
        OperationButtons.pack_start(SaveButtonMessageType, False, False, 0)
        OperationButtons.pack_start(DeleteButtonMessageType, False, False, 0)
        OperationButtons.pack_start(ClearButtonMessageType, False, False, 0)

        NewModifyView.pack_start(OperationButtons, False, False, 0)

        MessageTypeTabs.append_page(NewModifyView)
        MessageTypeTabs.set_tab_label_text(NewModifyView, "New/Modify")

        #End of New/Modify
        #Start of Template
        TemplateBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)

        ExistingMessageTypebox = Gtk.Box(spacing=0)
        ExistingMessageTypeLabel = Gtk.Label("Existing Message Type")
        ExistingMessageType = Gtk.Entry()
        ExistingMessageTypebox.pack_start(ExistingMessageTypeLabel, False,
                                          False, 0)
        ExistingMessageTypebox.pack_start(ExistingMessageType, False, False, 0)
        TemplateBox.pack_start(ExistingMessageTypebox, False, False, 0)

        CycleThroughPackets = Gtk.Button(label="Cycle Through Packets")
        TemplateBox.pack_start(CycleThroughPackets, False, False, 0)

        MessageTypeTemplateBox = Gtk.Box(spacing=0)
        MessageTypeTemplateLabel = Gtk.Label(
            "Message Type \n Template Field Value \n Pair(s)")
        PacketAreaField = Gtk.ListStore(str)
        PacketAreaField.append(["No packets"])

        PacketView = Gtk.TreeView(PacketAreaField)

        Render_Packet = Gtk.CellRendererText()
        PacketViewCol = Gtk.TreeViewColumn("Packets", Render_Packet, text=0)
        PacketView.append_column(PacketViewCol)

        MessageTypeTemplateBox.pack_start(MessageTypeTemplateLabel, False,
                                          False, 0)
        MessageTypeTemplateBox.pack_start(PacketView, False, False, 0)
        TemplateBox.pack_start(MessageTypeTemplateBox, False, False, 0)

        OperationButtonsTypeTemplate = Gtk.Box(spacing=2)
        SaveButtonTypeTemplate = Gtk.Button(label="Save")
        ClearButtonTypeTemplate = Gtk.Button(label="Clear")
        OperationButtonsTypeTemplate.pack_start(SaveButtonTypeTemplate, False,
                                                False, 0)
        OperationButtonsTypeTemplate.pack_start(ClearButtonTypeTemplate, False,
                                                False, 0)

        TemplateBox.pack_start(OperationButtonsTypeTemplate, False, False, 0)

        MessageTypeTabs.append_page(TemplateBox)
        MessageTypeTabs.set_tab_label_text(TemplateBox, "Template")
        #End of Template

        #Start of Equivalency
        EquivalencyBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                 spacing=0)
        FieldEquivalencyEqualBox = Gtk.Box(spacing=0)

        FieldEquivalencyLabel = Gtk.Label("Field Equivalency")
        FieldName = Gtk.Entry()
        FieldOR = Gtk.Label("OR")
        MessageType = Gtk.Entry()
        FieldEqual = Gtk.Label("=")
        FieldEquivalencyEqualBox.pack_start(FieldEquivalencyLabel, False,
                                            False, 0)
        FieldEquivalencyEqualBox.pack_start(FieldName, False, False, 0)
        FieldEquivalencyEqualBox.pack_start(FieldOR, False, False, 0)
        FieldEquivalencyEqualBox.pack_start(MessageType, False, False, 0)
        FieldEquivalencyEqualBox.pack_start(FieldEqual, False, False, 0)
        EquivalencyBox.pack_start(FieldEquivalencyEqualBox, False, False, 0)

        SecondFieldEquivalencyEqualBox = Gtk.Box(spacing=0)
        FieldName = Gtk.Entry()
        FieldOR = Gtk.Label("OR")
        IndentLabel = Gtk.Label("                           ")
        MessageType = Gtk.Entry()
        SecondFieldEquivalencyEqualBox.pack_start(IndentLabel, False, False, 0)
        SecondFieldEquivalencyEqualBox.pack_start(FieldName, False, False, 0)
        SecondFieldEquivalencyEqualBox.pack_start(FieldOR, False, False, 0)
        SecondFieldEquivalencyEqualBox.pack_start(MessageType, False, False, 0)
        FieldPLUS = Gtk.Label("+")
        SecondFieldEquivalencyEqualBox.pack_start(FieldPLUS, False, False, 0)
        EquivalencyBox.pack_start(SecondFieldEquivalencyEqualBox, False, False,
                                  0)

        OperationButtonsEquivalency = Gtk.Box(spacing=2)
        SaveButtonEquivalency = Gtk.Button(label="Save")
        ClearButtonEquivalency = Gtk.Button(label="Clear")
        OperationButtonsEquivalency.pack_start(SaveButtonEquivalency, False,
                                               False, 0)
        OperationButtonsEquivalency.pack_start(ClearButtonEquivalency, False,
                                               False, 0)

        EquivalencyBox.pack_start(OperationButtonsEquivalency, False, False, 0)

        MessageTypeTabs.append_page(EquivalencyBox)
        MessageTypeTabs.set_tab_label_text(EquivalencyBox, "Equivalency")

        #End of Equivalency

        #Start of Generation
        GenerationBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                spacing=0)
        ExistingMessageTypeInGeneration = Gtk.Box(spacing=0)
        ExistingMessageTypeLabel = Gtk.Label("Existing Message Type")
        ExistingMessageTypeInGeneration.pack_start(ExistingMessageTypeLabel,
                                                   False, False, 0)
        MessageTypeName = Gtk.Entry()
        ExistingMessageTypeInGeneration.pack_start(MessageTypeName, False,
                                                   False, 0)

        GenerationBox.pack_start(ExistingMessageTypeInGeneration, False, False,
                                 0)

        MessageTemplateFormatBox = Gtk.Box(spacing=0)
        MessageTemplateFormatLabel = Gtk.Label(
            "Message Template \n Output Format")
        MessageTemplateFormat = Gtk.Entry()
        MessageTemplateFormatBox.pack_start(MessageTemplateFormatLabel, False,
                                            False, 0)
        MessageTemplateFormatBox.pack_start(MessageTemplateFormat, False,
                                            False, 0)
        GenerationBox.pack_start(MessageTemplateFormatBox, False, False, 0)

        MessageTemplateNameBox = Gtk.Box(spacing=0)
        MessageTemplateNameLabel = Gtk.Label("Message Template \n Name")
        MessageTemplateName = Gtk.Entry()
        MessageTemplateNameBox.pack_start(MessageTemplateNameLabel, False,
                                          False, 0)
        MessageTemplateNameBox.pack_start(MessageTemplateName, False, False, 0)
        GenerationBox.pack_start(MessageTemplateNameBox, False, False, 0)

        ButtonsMessageType = Gtk.Box(spacing=0)
        GenerateButton = Gtk.Button(label="Generate")
        ClearMessageType = Gtk.Button(label="Clear")
        ButtonsMessageType.pack_start(GenerateButton, False, False, 0)
        ButtonsMessageType.pack_start(ClearMessageType, False, False, 0)
        GenerationBox.pack_start(ButtonsMessageType, False, False, 0)

        MessageTypeTabs.append_page(GenerationBox)
        MessageTypeTabs.set_tab_label_text(GenerationBox, "Generation")
        #End of Generation

        MessageTypeArea = Gtk.Label("Message Type Area")
        MessageTypeArea.set_text("Message Type")

        MessageTypeBox.pack_start(MessageTypeArea, False, False, 0)
        MessageTypeBox.pack_start(MessageTypeTabs, False, False, 0)
Exemplo n.º 27
0
 def __init__(self):
     self.header = Header()
     self.meta = Meta()
     self.grid = []
     self.objects = dict()
Exemplo n.º 28
0
def extract_pieces(msg_lines, msg_offset, mbx, inner_mesg=False):
    """Takes four parameters.  The first is a list of line strings
	containing the headers and body of a message from a Eudora MBX
	file.  The second is the offset of the first character in the
	first line in the msg_lines list within the MBX file we're
	processing.  The third is the name of the MBX file we're
	reading.  The fourth, inner_mesg, is a boolean controlling
	whether or not the pieces were are extracting are a top-level
	message in the MBX file.  If inner_mesg is true, we will carry
	out our processing under the assumption that we are handling
	an attached message carried in an message/rfc822 segment.
	
	Returns a tuple (header, body, attachments, embeddeds, mbx)
	containing a Header object, a body String containing the body
	of the message, a list of attachment definition tuples, a list
	of embedded definition tuples, and the name of the MBX file
	we're processing."""

    global toc_info, replies
    global target

    headers = Header()
    body = []
    attachments = []
    embeddeds = []

    in_headers = True
    found_rfc822_inner_mesg = False
    is_html = False

    if not inner_mesg:
        headers.add('From ', msg_lines[0][5:].strip())

    for line in msg_lines:
        if in_headers:
            if re_initial_whitespace.match(line):
                # Header "folding" (RFC 2822 3.2.3)
                headers.appendToLast(line)
            elif len(line.strip()) != 0:
                # Message header
                headers.add_line(line)

                attachment_matcher = re_x_attachment.match(line)

                if attachment_matcher:
                    files = attachment_matcher.group(1)
                    attach_list = re.split(';\s*', files)

                    for attachment in attach_list:
                        attachments.append((attachment, target))
            else:
                # End of message headers.

                # scrub the header lines we've scanned

                if not inner_mesg:
                    headers.clean(toc_info, msg_offset, replies)

                in_headers = False

                content_type = headers.getValue('Content-Type:')

                if content_type and content_type.lower() == 'message/rfc822':
                    found_rfc822_inner_mesg = True
                    print "+",
        elif found_rfc822_inner_mesg:
            # We're processing a message/rfc822 message,
            # and so we don't want to process attachments
            # at this level.  Instead, we want to properly
            # extract all body lines for later processing

            body.append(strip_linesep(line) + "\n")
        else:
            # We're in the body of the text and we need to
            # handle attachments

            if not is_html and re_xhtml.search(line) or re_normal_html.search(
                    line):
                is_html = True

            if attachments_dirs and re_attachment.search(line):
                # remove the newline that
                # Eudora inserts before the
                # 'Attachment Converted' line.

                if len(body) > 0 and (body[-1] == '\n' or body[-1] == '\r\n'):
                    body.pop()

                #EudoraLog.log.warn("Adding attachment with contenttype = " + contenttype)
                attachments.append((line, target))
            else:
                embedded_matcher = re_embedded.match(line)

                if embedded_matcher:
                    filename = embedded_matcher.group(1)
                    embeddeds.append(filename)
                else:
                    orig_line = line

                    if scrub_xflowed:
                        line = re.sub(re_xflowed, '', line)
                        line = re.sub(re_xhtml, '', line)
                        line = re.sub(re_pete_stuff, '', line)

                    if orig_line == line or line != '':
                        body.append(strip_linesep(line) + "\n")

    return (headers, body, attachments, embeddeds, mbx, is_html)
Exemplo n.º 29
0
 def __init__(self):
     super(Withdraw, self).__init__(Header(MessageType.withdraw))
Exemplo n.º 30
0
 def __init__(self, user, first_notebook, login_url, logout_url, note_title,
              *nodes):
     Page.__init__(
         self,
         (note_title != "home") and note_title
         or None,  # use the default title for the "home" page
         Link(rel=u"stylesheet",
              type=u"text/css",
              href=u"/static/css/header.css?%s" % VERSION),
         Link(rel=u"stylesheet",
              type=u"text/css",
              href=u"/static/css/product.css?%s" % VERSION),
         Meta(
             name=u"description",
             content=
             u"Luminotes is a WYSIWYG personal wiki notebook for organizing your notes and ideas."
         ),
         Meta(
             name=u"keywords",
             content=
             u"note taking, personal wiki, wysiwyg wiki, easy wiki, simple wiki, wiki notebook"
         ),
         Header(user, first_notebook, login_url, logout_url, note_title),
         Span(*nodes),
         Div(
             Div(
                 Div(
                     Div(
                         Ul(
                             Li(u"About", class_=u"footer_category"),
                             Li(A(u"tour", href=u"/tour")),
                             Li(A(u"demo", href=u"/users/demo")),
                             Li(A(u"faq", href=u"/faq")),
                             Li(A(u"team", href=u"/meet_the_team")),
                             Li(A(u"user guide", href=u"/guide")),
                             Li(A(u"privacy", href=u"/privacy")),
                             class_=u"footer_list",
                         ),
                         Ul(
                             Li(u"Get Started", class_=u"footer_category"),
                             Li(A(u"download", href=u"/download")),
                             Li(A(u"sign up", href=u"/pricing")),
                             Li(A(u"source code", href=u"/source_code")),
                             class_=u"footer_list",
                         ),
                         Ul(
                             Li(u"Community", class_=u"footer_category"),
                             Li(A(u"contact support",
                                  href=u"/contact_info")),
                             Li(A(u"discussion forums", href=u"/forums/")),
                             Li(A(u"blog", href=u"/blog/")),
                             Li(
                                 A(u"Facebook group",
                                   href=
                                   u"http://www.facebook.com/pages/Luminotes-personal-wiki-notebook/17143857741"
                                   )),
                             Li(
                                 A(u"Twitter stream",
                                   href=u"http://twitter.com/Luminotes")),
                             class_=u"footer_list",
                         ),
                         Ul(
                             Li(u"Copyright &copy;2008 Luminotes"),
                             class_=u"footer_list wide_footer_list",
                         ),
                         Br(),
                         class_=u"footer_column",
                     ),
                     class_=u"footer_links",
                 ),
                 class_=u"wide_center_area",
             ),
             class_=u"footer",
         ),
     )