Exemple #1
0
    def check_login(self, data):
        """
        check the syntax of the msg of log in.
        """
        edited_data = editor_data(data, True)
        dct_info = edited_data.dct_data
        str_return = "not correct log in"
        if dct_info.has_key("LOGIN") and dct_info.has_key("PASSWORD"):
            user_name = dct_info["LOGIN"]
            password = dct_info["PASSWORD"]

            print 'got login ' + user_name + " and " + password

            if self.sign_in(user_name, password):
                self.client_name = user_name
                self.password = password
                self.state = State_enum.logged_in
                str_return = []
                if dct_info.has_key("HEADERS"):
                    str_return = dct_info["HEADERS"]

        elif dct_info.has_key("NEW ACCOUNT") and dct_info.has_key("PASSWORD"):
            user_name = dct_info["NEW ACCOUNT"]
            password = dct_info["PASSWORD"]
            print 'got user ' + user_name + " and " + password
            if self.sign_up(user_name, password):
                self.client_name = user_name
                self.password = password
                self.state = State_enum.logged_in
                str_return = []
                if dct_info.has_key("HEADERS"):
                    str_return = dct_info["HEADERS"]
        return str_return
Exemple #2
0
    def check_what_client_want(self, data):
        """
        check what client ask for from server
        and act properley
        """
        edited_data = editor_data(data, True)
        dct_help = edited_data.dct_data
        if dct_help.has_key("NEW PROJECT") and dct_help.has_key("HEADERS"):

            name_new_pro = dct_help["NEW PROJECT"]
            is_succseed = user.add_new_project_to_user(self.user_name,
                                                       name_new_pro)
            """if not is_succseed:
                 self.send("not correct name")
            else:"""
            headers = dct_help["HEADERS"]
            self.send_client_info_pro("", headers)
        if dct_help.has_key("OPEN PROJECT") and dct_help.has_key("HEADERS"):

            name_pro = dct_help["OPEN PROJECT"]
            self.name_current_acc_pro = name_pro
            pro_help = project.acc_project(name_pro, self.user_name,
                                           self.password)
            to_send = pro_help.get_files_and_info_to_client(
                dct_help["HEADERS"])

            data_obj = editor_data(to_send, False)
            to_send = data_obj.data

            self.send_msg((to_send))

        if dct_help.has_key("NEW FILE") and dct_help.has_key(
                "HEADERS") and dct_help.has_key("CONTENT"):

            name_new_file = dct_help["NEW FILE"]
            pro = project.acc_project(self.name_current_acc_pro,
                                      self.user_name, self.password)
            content = dct_help["CONTENT"]
            pro.create_new_file(name_new_file, content)
            """if not is_succseed:
                 self.send("not correct name")
            else:"""
            headers = dct_help["HEADERS"]
            self.send_client_info_pro("", headers)
Exemple #3
0
    def OnItemSelected(self, evt):
        item = evt.GetItem()
        print "Item selected:", item.GetText()
        dct_to_dend = {"OPEN PROJECT": str(item.GetText())}
        editor = editor_data(dct_to_dend, False)

        editor.union_data({"HEADERS":headers_files})

        self.client_actions.send(editor.data)
        self.check_user_name_and_open_projects()
Exemple #4
0
    def Login(self,event):

        if self.user_name_input.Value==""  or self.Password.Value=="":
            code=(self.Massage_codes.Return_massage(6))
            self.call_massage_box(code[0],code[1])

        else:
            user_name = str(self.user_name_input.Value)
            password = str(self.Password.Value)
            dct_to_dend = {"LOGIN": user_name, "PASSWORD":password}
            editor = editor_data(dct_to_dend, False)

            editor.union_data({"HEADERS":headers_pros})

            self.client_actions.send(editor.data)
            self.check_user_name_and_open_projects()
Exemple #5
0
    def send_client_info_pro(self, data_before, headers):
        """
        the function send to the client all of his projects in a list:

        """
        try:
            to_send = user.get_projects_and_info_to_client(
                self.client_name, self.password, headers)
            if len(to_send) != 0:
                data_obj = editor_data(to_send, False)
                to_send = data_obj.data
            else:
                to_send = "0"
            self.send_msg((data_before + to_send))
        except Exception as err:
            print "problem is here:", err.args
Exemple #6
0
    def make_list_project(self, data):
        """
        the func gets a string that represent the table
        orginized it to to a list
        """

        editor = editor_data(data, True)
        dct_pros = editor.dct_data
        #'dct_pros' is a dictionary that the keys are the projects names nad the value is a list with the information about the project

        lst_projects = []

        for pro in dct_pros:
            tuple_info = tuple([pro]) + tuple(dct_pros[pro])
            lst_projects.append(tuple_info)
        if self.is_pro:
            headers = ["PROJECT"] + headers_pros
        else:
            headers = ["FILE"] + headers_files
        self.listed_obj  = Listed_object(headers, lst_projects)
Exemple #7
0
        def new_name_pro_file(self, event):
            if self.is_create_file:

                content = self.new_file_helper()
                dct_to_dend = {"NEW FILE": self.name_file, "CONTENT":content, "HEADERS": headers_files}

            else:
                dct_to_dend = {"NEW PROJECT": str(self.name_pro_or_file.Value), "HEADERS": headers_pros}
            editor = editor_data(dct_to_dend, False)

            self.client_actions.send(editor.data)

            recv = self.client_actions.recv()

            #the server will return :
            #"Confirm-User!\n\n\n..Edited-Name:\n\n\n...info of the pro\file:





            Acc_projects_or_files(self.client_actions, recv, self.is_create_file)
            self.Close()