raise cherrypy.HTTPError(404) def _get_user_suite_dir_root(self, user): """Return, e.g. ~user/cylc-run/ for a cylc suite.""" return self._check_dir_access(os.path.join( self._get_user_home(user), self.bush_dao.SUITE_DIR_REL_ROOT)) def _get_user_suite_dir(self, user, suite, *paths): """Return, e.g. ~user/cylc-run/suite/... for a cylc suite.""" return self._check_dir_access(os.path.join( self._get_user_home(user), self.bush_dao.SUITE_DIR_REL_ROOT, suite, *paths)) @staticmethod def _sort_summary_entries(suite1, suite2): """Sort suites by last_activity_time.""" return (cmp(suite2.get("last_activity_time"), suite1.get("last_activity_time")) or cmp(suite1["name"], suite2["name"])) if __name__ == "__main__": from rose.ws import ws_cli ws_cli(RoseBushService) else: from rose.ws import wsgi_app application = wsgi_app(RoseBushService)
self._check_path_normalised(suite) for path in paths: self._check_path_normalised(path) suite_dir = os.path.join(self._get_user_home(user), self.bush_dao.SUITE_DIR_REL_ROOT, suite) if not paths: return self._check_dir_access(suite_dir) path = os.path.join(suite_dir, *paths) if not path.startswith(suite_dir): # Raise HTTP 403 if path lies outside of the suite directory. Note: # >>> os.path.join('/foo', '/bar') # '/bar' raise cherrypy.HTTPError(403) return self._check_dir_access(path) @staticmethod def _sort_summary_entries(suite1, suite2): """Sort suites by last_activity_time.""" return (cmp(suite2.get("last_activity_time"), suite1.get("last_activity_time")) or cmp(suite1["name"], suite2["name"])) if __name__ == "__main__": from rose.ws import ws_cli ws_cli(RoseBushService) elif 'doctest' not in sys.argv[0]: # If called as a module but not by the doctest module. from rose.ws import wsgi_app application = wsgi_app(RoseBushService)
def _query_parse_string(q_str): """Split a query filter string into component parts.""" conjunction, tail = q_str.split(" ", 1) if conjunction == "or" or conjunction == "and": q_str = tail else: conjunction = "and" filt = [conjunction] if all(s == "(" for s in q_str.split(" ", 1)[0]): start_group, q_str = q_str.split(" ", 1) filt.append(start_group) key, operator, value = q_str.split(" ", 2) filt.extend([key, operator]) last_groups = value.rsplit(" ", 1) if (len(last_groups) > 1 and last_groups[1] and all([s == ")" for s in last_groups[1]])): filt.extend(last_groups) else: filt.extend([value]) return filt if __name__ == "__main__": from rose.ws import ws_cli ws_cli(RosieDiscoServiceRoot) else: from rose.ws import wsgi_app application = wsgi_app(RosieDiscoServiceRoot)