def c_getUniqueSoftwareSource(self): source = { "project_name": self.getUniqueStringForField(SoftwareSource, "project_name"), "branch_url": self.getUniqueStringForField(SoftwareSource, "branch_url"), "branch_vcs": self.getUniqueStringForField(SoftwareSource, "branch_vcs"), "branch_revision": self.getUniqueStringForField(SoftwareSource, "branch_revision"), } if self.commit_timestamp is not None: source["commit_timestamp"] = datetime_extension.to_json(self.commit_timestamp) return source
def invoke_remote(self): if not os.path.exists(self.args.BACKUP_DIR): os.mkdir(self.args.BACKUP_DIR) for bundle_stream in self.server.streams(): print "Processing stream %s" % bundle_stream["pathname"] bundle_stream_dir = os.path.join( self.args.BACKUP_DIR, urllib.quote_plus(bundle_stream["pathname"])) if not os.path.exists(bundle_stream_dir): os.mkdir(bundle_stream_dir) with open(os.path.join(bundle_stream_dir, "metadata.json"), "wt") as stream: simplejson.dump({ "pathname": bundle_stream["pathname"], "name": bundle_stream["name"], "user": bundle_stream["user"], "group": bundle_stream["group"], }, stream) for bundle in self.server.bundles(bundle_stream["pathname"]): print " * Backing up bundle %s" % bundle["content_sha1"] data = self.server.get(bundle["content_sha1"]) bundle_pathname = os.path.join( bundle_stream_dir, bundle["content_sha1"]) # Note: we write bundles as binary data to preserve anything # the user might have dumped on us with open(bundle_pathname + ".json", "wb") as stream: stream.write(data["content"]) with open(bundle_pathname + ".metadata.json", "wt") as stream: simplejson.dump({ "uploaded_by": bundle["uploaded_by"], "uploaded_on": datetime_extension.to_json(bundle["uploaded_on"]), "content_filename": bundle["content_filename"], "content_sha1": bundle["content_sha1"], "content_size": bundle["content_size"], }, stream)
def _set_value(self, new_value): if isinstance(new_value, datetime.datetime): new_value = datetime_extension.to_json(new_value) if isinstance(new_value, datetime.timedelta): new_value = timedelta_extension.to_json(new_value) super(JSONDocumentFragment, self)._set_value(new_value)
def _set_value(self, new_value): if isinstance(new_value, datetime.datetime): new_value = datetime_extension.to_json(new_value) if isinstance(new_value, datetime.timedelta): new_value = timedelta_extension.to_json(new_value) super(JSONDocumentFragment, self)._set_value(new_value)