How to use the foolscap.base32.encode function in foolscap

To help you get started, we’ve selected a few foolscap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github warner / foolscap / src / foolscap / pb.py View on Github external
def generateSwissnumber(bits):
    bytes = os.urandom(bits//8)
    return base32.encode(bytes)
github warner / foolscap / src / foolscap / logging / tail.py View on Github external
def short_tubid_b2a(tubid):
    return base32.encode(tubid)[:8]
github warner / foolscap / foolscap / logging / incident.py View on Github external
def incident_declared(self, triggering_event):
        self.trigger = triggering_event
        # choose a name for the logfile
        now = time.time()
        unique = os.urandom(4)
        unique_s = base32.encode(unique)
        self.name = "incident-%s-%s" % (self.format_time(now), unique_s)
        filename = self.name + ".flog"
        self.abs_filename = os.path.join(self.basedir, filename)
        self.abs_filename_bz2 = self.abs_filename + ".bz2"
        self.abs_filename_bz2_tmp = self.abs_filename + ".bz2.tmp"
        # open logfile. We use both an uncompressed one and a compressed one.
        try:
            self.f1 = open(self.abs_filename, "wb")
            self.f2 = bz2.BZ2File(self.abs_filename_bz2_tmp, "wb")
        except EnvironmentError as e:
            raise IncidentDeclarationError(e)

        # write header with triggering_event
        flogfile.serialize_header(self.f1, "incident",
                                  trigger=triggering_event,
                                  versions=app_versions.versions,
github warner / foolscap / src / foolscap / logging / web.py View on Github external
def __init__(self, e):
        self.e = e
        self.parent = None
        self.children = []
        self.index = None
        self.anchor_index = "no-number"
        self.incarnation = base32.encode(e['d']['incarnation'][0].encode("utf-8"))
        if 'num' in e['d']:
            self.index = (e['from'], e['d']['num'])
            self.anchor_index = "%s_%s_%d" % (quote(e['from'].encode("utf-8")),
                                              self.incarnation.encode("utf-8"),
                                              e['d']['num'])
        self.parent_index = None
        if 'parent' in e['d']:
            self.parent_index = (e['from'], e['d']['parent'])
        self.is_trigger = False