ConDict

Check-in [69bd115d2a]
Login

Check-in [69bd115d2a]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:done ticket #042743641b
Timelines: family | ancestors | descendants | both | testing
Files: files | file ages | folders
SHA1: 69bd115d2accb04771f3232f3f015371ecd0b9c3
User & Date: zorro 2012-10-16 19:10:15.826
Context
2012-10-17
11:10
fixed bug in command .info check-in: e03a7f02c8 user: alzay tags: testing
2012-10-16
19:10
done ticket #042743641b check-in: 69bd115d2a user: zorro tags: testing
2012-10-12
12:21
default command = en-ru translate check-in: 53a4d2e45c user: alzay tags: testing
Changes
Unified Diff Ignore Whitespace Patch
Changes to condt.py.
68
69
70
71
72
73
74


75
76
77
78
79
80
81
            'full': 'start ru-en test'},
        '.testmix': {'desc': 'start en-ru test', 'command': None,
            'full': 'start mix test'},
        '.testinfo': {'desc': 'information by test', 'command': None,
            'full': 'full test information by test ID'},
        '.testlist': {'desc': 'list of tests', 'command': None,
            'full': 'this command print list of your tests'},


        }
    def __init__(self, name, dbfile, debug, ctest=10):
        super().__init__(name, dbfile, debug)       
        self.__pcounter = 3
        self.ctest = ctest
        self.init_command()
        self.user_id = self.get_user()







>
>







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
            'full': 'start ru-en test'},
        '.testmix': {'desc': 'start en-ru test', 'command': None,
            'full': 'start mix test'},
        '.testinfo': {'desc': 'information by test', 'command': None,
            'full': 'full test information by test ID'},
        '.testlist': {'desc': 'list of tests', 'command': None,
            'full': 'this command print list of your tests'},
        '.info': {'desc': 'information about dictionary', 'command': None,
            'full': 'print information: user info, dictionary info, test info'},
        }
    def __init__(self, name, dbfile, debug, ctest=10):
        super().__init__(name, dbfile, debug)       
        self.__pcounter = 3
        self.ctest = ctest
        self.init_command()
        self.user_id = self.get_user()
110
111
112
113
114
115
116

117
118
119
120
121
122
123
        self.COMMANDS['.edit']['command'] = self.command_edit
        self.COMMANDS['.delete']['command'] = self.command_delete
        self.COMMANDS['.test']['command'] = self.command_testen
        self.COMMANDS['.testru']['command'] = self.command_testru
        self.COMMANDS['.testmix']['command'] = self.command_testmix
        self.COMMANDS['.testlist']['command'] = self.command_testlist
        self.COMMANDS['.testinfo']['command'] = self.command_testinfo


    def hash_pass(self, password):
        """create password hash: text => hast string"""
        result = bytes(password.strip() + SALT, 'utf-8')
        result = bytes(hashlib.md5(result).hexdigest(), 'utf-8')
        return hashlib.sha1(result).hexdigest()








>







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
        self.COMMANDS['.edit']['command'] = self.command_edit
        self.COMMANDS['.delete']['command'] = self.command_delete
        self.COMMANDS['.test']['command'] = self.command_testen
        self.COMMANDS['.testru']['command'] = self.command_testru
        self.COMMANDS['.testmix']['command'] = self.command_testmix
        self.COMMANDS['.testlist']['command'] = self.command_testlist
        self.COMMANDS['.testinfo']['command'] = self.command_testinfo
        self.COMMANDS['.info']['command'] = self.command_info

    def hash_pass(self, password):
        """create password hash: text => hast string"""
        result = bytes(password.strip() + SALT, 'utf-8')
        result = bytes(hashlib.md5(result).hexdigest(), 'utf-8')
        return hashlib.sha1(result).hexdigest()

720
721
722
723
724
725
726
727


















            self.prer(er)
            print("Error, use <.tesinfo ID> (ID - number)")
        except sqlite3.DatabaseError as er:
            self.prer(er)
            print("Error")
        cur.close()
        return 'testinfo'



























>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
            self.prer(er)
            print("Error, use <.tesinfo ID> (ID - number)")
        except sqlite3.DatabaseError as er:
            self.prer(er)
            print("Error")
        cur.close()
        return 'testinfo'

    def command_info(self, arg=None):
        cur = self.connect.cursor()
        # user
        cur.execute("SELECT `name`, `full` FROM `user` WHERE `id`=(?)", (self.user_id,))
        result = cur.fetchone()
        print("{0}: {1}".format(*result))
        cur.execute("SELECT COUNT(*) FROM `translate` WHERE `user_id`=(?) GROUP BY `user_id`", (self.user_id,))
        result = cur.fetchone()
        print("There are {0} records in user dictionary".format(result[0]))
        cur.execute("SELECT COUNT(*) FROM `test` WHERE `user_id`=(?) GROUP BY `user_id`", (self.user_id,))
        result = cur.fetchone()
        cur.execute("SELECT COUNT(*) FROM `result` LEFT JOIN `test` WHERE `test`.`user_id`=(?) GROUP BY `user_id`", (self.user_id,))
        results = cur.fetchone()
        print("There are {0} tests, with {1} results".format(result[0], results[0]))
        cur.close()
        return 'info'