From b34e6c27aa640e4bd4bde91d684e1e59095ba8b1 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 20 Jul 2017 14:24:08 +0200 Subject: Moved files Moved all files of lib into a lib dir --- commands.py | 56 -------------------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 commands.py (limited to 'commands.py') diff --git a/commands.py b/commands.py deleted file mode 100644 index c9525db..0000000 --- a/commands.py +++ /dev/null @@ -1,56 +0,0 @@ -from classes import userexist, PersonalError, r, host, clear, Colors -from listcommands import ListCommands - -class Commands(object): - - def command(self, what, cmd): - if what == 'clear': - clear() - elif what == 'set': - try: - if cmd[1] == 'user' and cmd[2] is not None: - if len(cmd[2]) > 10: raise PersonalError('lunghezza maggiore del consetito. Max 10') - - if userexist(cmd[2]) == True: raise PersonalError('questo nome utente esiste giĆ ') - - if len(cmd) > ListCommands.info['set'][1]: raise PersonalError(Colors.grey + 'set user' + Colors.red + ' accetta 1 parametro') - - if self.user != '': r.zrem('usersname', self.user) - - self.user = cmd[2] - r.hset('user:'+host, 'name', self.user) - r.zadd('usersname', self.user, 0) - - print('Ok') - elif cmd[1] is not ListCommands.commands['set']: - raise IndexError - except IndexError: - ListCommands.err('wrong') - except PersonalError as e: - ListCommands.err('personal', e.value) - elif what == 'get': - try: - if len(cmd) > 2 and cmd[1] != 'user?': raise PersonalError(Colors.grey + 'get ' + Colors.red + 'accetta 1 parametro') - - if cmd[1] == 'user': - if self.user != '': - print(r.hget('user:'+host, 'name').decode('utf-8')) - else: - print('nil') - elif cmd[1] == 'host': - print('localhost') - elif cmd[1] == 'port': - print('6379') - elif cmd[1] == 'user?': - if len(cmd) > 3: raise PersonalError(Colors.grey + 'get user?' + Colors.red + ' accetta 1 parametro') - print(userexist(cmd[2])) - elif cmd[1] not in ListCommands.commands: - raise KeyError - else: - raise IndexError - except IndexError: - ListCommands.err('wrong') - except KeyError: - ListCommands.err('keyword') - except PersonalError as e: - ListCommands.err('personal', e.value) -- cgit v1.2.3-18-g5258