Example #1
0
def run_ngrok():
    ngrok_config = pathlib_Path(".config/ngrok.yml")
    if ngrok_config.exists():
        pid = check_process("ngrok")
        for p in pid:
            kill_process(p, signal.SIGKILL)
        # Continue
        run_command('./ngrok tcp -config=.config/ngrok.yml 443 > /dev/null 2>&1 &')
        while True:
            tcp = sys_url('curl -s -N http://127.0.0.1:4040/status | grep -o "tcp://[0-9]*.tcp.ngrok.io:[0-9]*"').read()
            if re.match("tcp://[0-9]*.tcp.ngrok.io:[0-9]*", tcp) != None:
                print("\n{0}Ngrok TCP: {1}{2}".format(GREEN, DEFAULT, tcp))
                break
    else:
        while True:
            token = entry_token(title="SET NGROK AUTHTOKEN", text="Register at https://ngrok.com", width=450, height=140)        
            if token is None:
                continue
            else:
                ngrok_config.touch(mode=0o777, exist_ok=True)
                ngrok_config = open('.config/ngrok.yml','w')
                ngrok_config.write("authtoken: " + token)
                ngrok_config.close()        
                run_ngrok() 
                break
Example #2
0
def main():
    global mirror, google_assistant, status_handler
    run_command('xset s off')
    run_command('xset -dpms')

    mirror = Mirror()
    google_assistant = Google_Assistant()
    status_handler = Status_Handler()
    status_handler.start()
    google_assistant.start()
    mirror.tk.mainloop()
Example #3
0
def channel_hopper():
    while True:
        try:
            log.debug("Setting [{0}] channel to [{1}]".format(
                monitoring_interface, channel_hopper_scan_list))
            # Note that this next command occasionally throws '-22' errors to STDERR which can be ignored
            run_command("iw dev {0} set channel {1}".format(
                monitoring_interface, channel_hopper_scan_list))
            sleep(channel_hopper_scan_rate)
        except KeyboardInterrupt:
            break
Example #4
0
    def status_detect_func(self):
        while True:
            #print ("Display Status: %s"%self.display_status)
            if self.display_status == None:
                pass
            elif self.display_status == 'SCREENSAVER':
                if conf.screensaver == 'MIRROR':
                    self.random_timer_stop()
                elif conf.screensaver == 'RANDOM':
                    self.random_pic()
                    self.random_timer_stop()
                    self.random_timer_start()
                elif conf.screensaver == 'DEFAULT':
                    self.random_timer_stop()
                    self.show_pic(conf.screensaver_default)
                    run_command('xset s off')
                self.display_status = None

            elif self.display_status == 'CLEANUP':
                print("cleanup")
                self.sleep_timer.cancel()
                self.sleep_timer_func()
            elif self.display_status == 'GREETINGS':
                self.show_message('Hello')
            elif self.display_status == 'DATETIME':
                self.show_datetime()
            elif self.display_status == 'WEATHER':
                self.show_weather()
            elif self.display_status == 'NEWS':
                self.show_news()
            elif 'NEWS_DETAIL' in self.display_status:
                self.show_news_detail()
            elif 'SCREENSAVER' in self.display_status:
                temp = self.display_status.split(' ')[1]
                conf.screensaver = temp
                self.show_message('OK\nscreensaver set to %s' % temp)
                time.sleep(2)
                self.close_all()
                self.display_status = 'SCREENSAVER'
            else:
                pass
            time.sleep(1)
Example #5
0
def run():
  DATABASE = {}
  
  # Backup original file to compared later
  for file in FILES:
    filename = file.replace('/', '.').lstrip('.')
    tmp_file = path.join(REPOSITORY, filename)
    run_command('cp %s %s' % (file, tmp_file))
    
  while True:
    for file in FILES:
      filename = file.replace('/', '.').lstrip('.')
      mtime = stat(file).st_mtime
      
      tmp_file = path.join(REPOSITORY, filename)
      revision_name = '%s.%s' % (tmp_file, int(time()))
      
      if DATABASE.has_key(filename) and DATABASE.get(filename) != mtime:  # file changed
        print 'file %s changed' % file
        
        html = diff(tmp_file, file)
        open('%s.html' % revision_name, 'w').write(html)  # save html file to disk
        
        run_command("diff -u %s %s > %s.patch" % (tmp_file, file, revision_name))   # save patch file
        text = open('%s.patch' % revision_name).read()
        
        if SEND_EMAIL_NOTIFICATION:
          # Now, send changes to admins
          headers = {'From': '*****@*****.**',
                     'To': RECIPIENTS,
                     'Subject': 'File %s changed' % file}
          email_it_via_gmail(headers, text, html)
              
        run_command("cp %s %s" % (file, tmp_file))
      DATABASE[filename] = mtime
    sleep(REFRESH_TIME)
 def active_screen(self):
     cmd = "xset s activate"
     run_command(cmd)
 def set_screen_saver(self, sec):
     cmd = "xset s on s %s" % sec
     run_command(cmd)
 def disable_screen_saver(self, sec):
     cmd = "xset s reset"
     run_command(cmd)
Example #9
0
 def disable_screen_sleep(self):
     cmd = "xset s reset"
     run_command(cmd)
def clear():
    """Clears the console"""
    run_command('cls' if os_name == 'nt' else 'clear')
Example #11
0
def mkdir(dirname):
    """makes a directory"""
    from os import system as run_command
    return run_command("mkdir -p " + dirname)
Example #12
0
def mkdir(dirname):
    """Performs the equivalent of bash shell mkdir -p"""
    from os import system as run_command
    return run_command('mkdir -p ' + dirname)