pyqi commands and middleware