def dobackup(server,profile=None): if screen.check_screen_exists(server.name): screen.send_to_server(server.name,"\nsave-off\nsave-all\n") time.sleep(30) try: backups.backup(server.data["dir"],server.data['backup'],profile) except backups.BackupError as ex: raise ServerError("Error backing up server: {}".format(ex)) finally: if screen.check_screen_exists(server.name): screen.send_to_server(server.name,"\nsave-on\nsave-all\n")
def dobackup(server,profile=None): if screen.check_screen_exists(server.name): screen.send_to_server(server.name,"\nsave-off\nsave-all\n") time.sleep(30) try: backups.backup(server.data["dir"],server.data['backup'],profile) except backups.BackupError as ex: raise ServerError("Error backing up server: {}".format(ex)) finally: if screen.check_screen_exists(server.name): screen.send_to_server(server.name,"\nsave-on\nsave-all\n")
def message(server,msg,*targets,parse=False): if len(targets)<1: targets=["@a"] if parse and "@" in msg: msglist=[] pat=re.compile(r"([^@]*[^\\])?(@.(?:\[[^\]]+\])?)") while True: match=pat.match(msg) if match is None: break if match.group(1) is not None: msglist.append(match.group(1)) # group is optional # nothing stopping two selectors straight after each other msglist.append({"selector":match.group(2)}) msg=msg[match.end(0):] msglist.append(msg) msgjson=json.dumps(msglist) else: msgjson=json.dumps({"text":msg}) cmd="\n".join("tellraw "+target+" "+msgjson for target in targets) print(cmd) screen.send_to_server(server.name,"\n"+cmd+"\n")
def message(server,msg,*targets,parse=False): if len(targets)<1: targets=["@a"] if parse and "@" in msg: msglist=[] pat=re.compile(r"([^@]*[^\\])?(@.(?:\[[^\]]+\])?)") while True: match=pat.match(msg) if match is None: break if match.group(1) is not None: msglist.append(match.group(1)) # group is optional # nothing stopping two selectors straight after each other msglist.append({"selector":match.group(2)}) msg=msg[match.end(0):] msglist.append(msg) msgjson=json.dumps(msglist) else: msgjson=json.dumps({"text":msg}) cmd="\n".join("tellraw "+target+" "+msgjson for target in targets) print(cmd) screen.send_to_server(server.name,"\n"+cmd+"\n")
def do_stop(server,j): screen.send_to_server(server.name,"\nend\n")
def deop(server,*users): for user in users: screen.send_to_server(server.name,"\ndeop "+user+"\n")
def do_stop(server,j): screen.send_to_server(server.name,"\nstop\n")
def deop(server,*users): for user in users: screen.send_to_server(server.name,"\ndeop "+user+"\n")