def api_get(self, request): c = CPClient() data = {} if c.has_account(): data["account"] = c.account_info() for i in data["account"].get("industries", []): data["account"]["ind_%s" % i] = True if c.has_system(): data["system"] = c.system_info() return data
def handle_upgrade(status, log, quiet=False): cp = CPClient() if not cp.has_system(): die("System is not registred", quiet) if log: with open(log) as f: log = f.read() try: cp.upgrade(status, log) except CPClient.Error, why: die("RPC Error: %s" % why, quiet)
def report(self): logger.info("Reporting crashinfo %s", self.uuid) if self.status not in ("N", "r"): raise CPClient.Error("Cannot share not-new crashinfo") cp = CPClient() if not cp.has_system(): raise CPClient.Error("System is not registred") ci = self.json ci["comment"] = self.comment ci["priority"] = self.priority cp.report_crashinfo(ci) self.status = "R" self.save()
def api_save_system(self, request, name, type=None, description=None, *args, **kwargs): c = CPClient() if c.has_system(): try: c.update_system(name, type, description=description) except CPClient.Error, why: return {"status": False, "message": str(why)}
def api_save_system(self, request, name, type=None, description=None, *args, **kwargs): c = CPClient() if c.has_system(): try: c.update_system(name, type, description=description) except CPClient.Error as e: return {"status": False, "message": str(e)} else: # Create account try: c.create_system(name, type, description=description) except CPClient.Error as e: return {"status": False, "message": str(e)} return {"status": True, "message": "System saved"}
def main(): parser = OptionParser() parser.add_option("--public", dest="public", action="store_true", default=False, help="Create public paste"), parser.add_option("-s", "--subject", dest="subject", action="store", help="Create paste subject") parser.add_option("-e", "--expire", dest="expire", action="store", help="Set expiration time") parser.add_option("-q", "--quiet", dest="quiet", action="store_true") parser.add_option("-v", "--verbose", dest="verbose", action="store_true") options, args = parser.parse_args() if options.verbose: logging.basicConfig(level=logging.DEBUG) elif options.quiet: logging.basicConfig(level=logging.CRITICAL) else: logging.basicConfig() cp = CPClient() quiet = bool(options.quiet) if not cp.has_system(): die("System is not registred", quiet) if args: data = [] for a in args: with open(a) as f: data += [f.read()] data = "".join(data) else: data = sys.stdin.read() print( cp.create_paste( subject=options.subject, data=data, syntax=None, ttl=parse_ttl(options.expire), public=bool(options.public), )["url"])