def main(): '''Get, interpret, and pass on any commands''' # Find and import support files path = os.getenv('HOME') + '/.jot' sys.path.append(path) # Class modules from lib import item, connection, peer # Command modules from bin import add, version, remove, show, util, \ config, search, edit, pull, push, clone, \ log, tag # Parse the configuration file config = util.parseConfig() # Apply changelog util.processChangelog() # Parse the command/arguments args = [] if len(sys.argv) > 1: command = sys.argv[1] else: return False if len(sys.argv) > 2: args = util.parseArgs(sys.argv[2:]) if len(args) > 0: args = util.parseArgs(args) # Create a database connection db = connection.Connection() # Pass off the db and any arguments to a # command-specific function. if command == 'add': add.add(db,args,config) elif command == 'version': version.version() elif command == 'remove' or command == 'rm': remove.remove(db,args) elif command == 'config': config.config(args) elif command == 'show': show.show(db,args) elif command == 'search': search.search(db,args) elif command == 'edit': edit.edit(db,args,config) elif command == 'pull': pull.pull(args) elif command == 'push': push.push(args) elif command == 'clone': clone.clone(db,args) elif command == 'log': log.log(args,config) elif command == 'tag': tag.tag(db,args) elif command == 'help': help() else: print util.decorate('FAIL','Fatal: Command not recognized.') guess = util.guessCommand(command) if guess is not None: print 'Did you mean:',' or '.join(guess) return False return True
def pull(self): '''Pull the changelog from the peer.''' receivepath = self.changelog + '.' + hashlib.md5(str(time.time())).hexdigest() command = 'scp -q %s:%s %s' % (self.address,self.changelog,receivepath) os.system(command) util.processChangelog() # We can process the changelog immediately
def main(): """Get, interpret, and pass on any commands""" # Find and import support files path = os.getenv("HOME") + "/.jot" sys.path.append(path) # Class modules from lib import item, connection, peer # Command modules from bin import add, version, remove, show, util, config, search, edit, pull, push, clone, log, tag # Parse the configuration file config = util.parseConfig() # Apply changelog util.processChangelog() # Parse the command/arguments args = [] if len(sys.argv) > 1: command = sys.argv[1] else: return False if len(sys.argv) > 2: args = util.parseArgs(sys.argv[2:]) if len(args) > 0: args = util.parseArgs(args) # Create a database connection db = connection.Connection() # Pass off the db and any arguments to a # command-specific function. if command == "add": add.add(db, args, config) elif command == "version": version.version() elif command == "remove" or command == "rm": remove.remove(db, args) elif command == "config": config.config(args) elif command == "show": show.show(db, args) elif command == "search": search.search(db, args) elif command == "edit": edit.edit(db, args, config) elif command == "pull": pull.pull(args) elif command == "push": push.push(args) elif command == "clone": clone.clone(db, args) elif command == "log": log.log(args, config) elif command == "tag": tag.tag(db, args) else: print util.decorate("FAIL", "Fatal: Command not recognized.") guess = util.guessCommand(command) if guess is not None: print "Did you mean:", " or ".join(guess) return False return True