Exemplo n.º 1
0
 def test_escape_ansi(self):
     msg = "test"
     for color in dir(Colors):
         color = getattr(Colors, color)
         try:
             if '[' not in color and r'\0' not in color: continue
         except TypeError:
             continue
         try:
             self.assertEqual(escape_ANSI(color + msg), msg)
         except TypeError:
             pass
         self.assertEqual(escape_ANSI(msg), msg)
Exemplo n.º 2
0
 def showOutput(self):
     while type(self.channel) is type(None) and self.flowRunning:
         time.sleep(1)
     try:
         while self.flowRunning:
             for block in blockmetadb.get_blocks_by_type('brd'):
                 if block in self.alreadyOutputed:
                     continue
                 block = Block(block)
                 b_hash = bytesconverter.bytes_to_str(block.getHash())
                 if block.getMetadata('ch') != self.channel:
                     continue
                 if not self.flowRunning:
                     break
                 logger.info('\n------------------------',
                             prompt=False, terminal=True)
                 content = block.getContent()
                 # Escape new lines, remove trailing whitespace, and escape ansi sequences
                 content = escapeansi.escape_ANSI(content.replace(
                     b'\n', b'\\n').replace(b'\r', b'\\r').strip().decode('utf-8'))
                 logger.info(block.getDate().strftime(
                     "%m/%d %H:%M") + ' - ' + logger.colors.reset + content, prompt=False, terminal=True)
                 self.alreadyOutputed.append(b_hash)
             time.sleep(5)
     except KeyboardInterrupt:
         self.flowRunning = False
Exemplo n.º 3
0
 def test_circles_home_load(self):
     Popen(['./onionr.sh', 'start'])
     while b'http' not in Popen(['./onionr.sh', 'url'],
                                stdout=subprocess.PIPE).communicate()[0]:
         sleep(1)
     url = 'http' + escapeansi.escape_ANSI(
         Popen(['./onionr.sh', 'url'], stdout=subprocess.PIPE).communicate(
         )[0].decode().split('http')[1])
     web_driver = start_firefox(url=url, headless=BROWSER_HEADLESS)
     if not Text('Circles').exists():
         click('Get Started')
     sleep(2)
     click('Circles')
     sleep(5)
     if not Text('Circle Name').exists():
         Popen(['./onionr.sh', 'stop']).wait()
         web_driver.quit()
         raise ValueError
     Popen(['./onionr.sh', 'stop']).wait()
     web_driver.quit()
Exemplo n.º 4
0
 def test_no_replace(self):
     msg = 'test message'
     self.assertEqual(escape_ANSI(msg), msg)