示例#1
0
 def gen_shared_password(self):
     pwd=generate_password()
     hpwd=hash_password(pwd)
     self.config["gen_password_shared"] = hpwd
     save_config(self.config)
     #set text for widget with password
     self.label_set_gen_password_shared.set_text(pwd)
示例#2
0
 def stop(self, widget, data=None):
     """Stop web server"""
     if stop_server(self.config):
         self.server=None
     self.setstatus()
     self.toggle_start_stop_buttons()
     #save config
     save_config(self.config)
示例#3
0
    def onsave(self, widget, data=None):
        """Save options configuration"""
        from main import SECRET_KEY

        passwd = self.entry_set_pass.get_text()
        check = self.check_startup.get_active()
        port = self.entry_set_port.get_text()
        hashed=hashlib.md5()
        hashed.update(SECRET_KEY+passwd)
        if passwd:
            self.config["password"] = hashed.hexdigest()
        self.config["startup"] = check
        self.config["port"] = int(port)
        self.config["images_path"] = self.chooser_image_folder.get_filename()
        save_config(self.config)
        self.destroy()
示例#4
0
    def start(self, widget, data=None):
        """Start web server"""
        if self.server:return

        serv=start_server(self.config)
        if serv:
            self.server=serv

        self.toggle_start_stop_buttons()

        #set status
        self.setstatus()
        save_config(self.config)

        print("Web server started")
        ddd = subprocess.Popen("/usr/bin/notify-send Server Started", shell=True)
        ddd.poll()
示例#5
0
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title("U-Air Launcher")
        self.set_icon_from_file(ICON_PATH)
        self.set_resizable(False)
        self.set_size_request(440, 320)
        self.set_border_width(20)
        self.set_position(gtk.WIN_POS_CENTER)

        #load config
        self.config=load_config()
        save_config(self.config)

        #www server process
        self.server=None

        #get lang from config
        self.lang=self.config.get("lang", "en")

        #connect close event
        self.connect("destroy", self.close_app)

        self.fixed = gtk.Fixed()

        self.label_status = gtk.Label("Status:")
        self.label_status.set_text(lt("Status", self.lang)+":")

        #local IP label
        self.label_local_ip = gtk.Label("Local IP:")
        label=lt("Local IP", self.lang)+": "+self.config["local_ip"]
        label+=":"+str(self.config["port"])
        self.label_local_ip.set_text(label)

        self.label_public_ip = gtk.Label("Public IP:")
        label=lt("Public IP", self.lang)+": "+self.config["global_ip"]+":"+str(self.config["port"])
        self.label_public_ip.set_text(label)
        self.label_gen_password = gtk.Label("Login password:"******"Login password", self.lang)+":")
        self.label_gen_password_shared = gtk.Label("Shared password:"******"Shared password", self.lang)+":")
        self.label_set_gen_password = gtk.Label("...")
        self.label_set_gen_password_shared = gtk.Label("...")
        self.button_regenerate = gtk.Button("Regenerate password")
        self.button_regenerate.set_label(lt("Regenerate password", self.lang))
        self.button_regenerate.connect("clicked", self.regenerate)

        self.button_start = gtk.Button("Start")
        self.button_start.set_label(lt("Start", self.lang))
        self.button_start.connect("clicked", self.start)
        self.button_start.set_size_request(110, 50)
        self.button_stop = gtk.Button("Stop")
        self.button_stop.set_label(lt("Stop", self.lang))
        self.button_stop.connect("clicked", self.stop)
        self.button_stop.set_size_request(110, 50)

        self.button_options = gtk.Button("Options")
        self.button_options.set_label(lt("Options", self.lang))
        self.button_options.set_size_request(130, 30)
        self.button_options.connect("clicked", self.show_option_window)
        self.button_about = gtk.Button("About")
        self.button_about.set_label(lt("About", self.lang))
        self.button_about.set_size_request(130, 30)
        self.button_about.connect("clicked", self.show_about_window)
        self.button_quit = gtk.Button("Quit")
        self.button_quit.set_label(lt("Quit", self.lang))
        self.button_quit.set_size_request(130, 30)
        self.button_quit.connect("clicked", self.close_app)

        self.img_banner = gtk.Image()
        self.img_banner.set_from_file(os.path.join(ROOT_PATH,
            "static/banner1.png"))

        self.fixed.put(self.img_banner, 0, 0)
        self.fixed.put(self.label_status, 5, 5)
        #self.fixed.put(self.label_local_ip, 3, 130)
        #self.fixed.put(self.label_public_ip, 200 ,130)
        self.fixed.put(self.label_local_ip, 5, 110)
        self.fixed.put(self.label_public_ip, 5 ,130)
        self.fixed.put(self.button_regenerate, 70, 200)

        self.fixed.put(self.button_start, 0, 230)
        self.fixed.put(self.button_stop, 120, 230)

        self.fixed.put(self.label_gen_password, 0, 160)
        self.fixed.put(self.label_set_gen_password, 150, 160)
        self.fixed.put(self.label_gen_password_shared, 0, 180)
        self.fixed.put(self.label_set_gen_password_shared, 150, 180)

        self.fixed.put(self.button_options, 250, 170)
        self.fixed.put(self.button_about, 250, 210)
        self.fixed.put(self.button_quit, 250, 250)
        self.add(self.fixed)
        #show all
        self.show_all()
        #create pictures folder if not exist
        if not os.path.exists(DEFAULT_IMAGES_PATH):
            os.mkdir(DEFAULT_IMAGES_PATH)
        #remove pid file when process not exist
        remove_orphaned_pidfile(check_pidfile())
        #set status
        self.setstatus()
        #update start stop buttons
        self.toggle_start_stop_buttons()
        #generate new login password
        self.gen_login_password()
        self.gen_shared_password()
示例#6
0
            exit(0)
        gip=get_global_ip_address()
        lip=get_local_ip_address()
        #print addresses
        print("Local IP: %s" % lip)
        print("Public IP: %s" % gip)
        #gen passwords
        pass1=generate_password()
        pass2=generate_password()
        config["gen_password"]=hash_password(pass1)
        config["gen_password_shared"]=hash_password(pass2)
        print("Login password:%s" % pass1)
        print("Shared password:%s" % pass2)
        config["local_ip"]=lip
        config["global_ip"]=gip
        save_config(config)
        start_server(config)
        config["status"]=1
        save_config(config)



    if sys.argv[1]=="stop":
        done=stop_server(config)
        if done:
            config["status"]=0
            save_config(config)

    if sys.argv[1]=="password" and len(sys.argv)>2:
        config["password"]=hash_password(sys.argv[2].strip())
        save_config(config)