Example #1
0
def get_string(dbo, name, path=""):
    """
    Gets DBFS file contents as a string. Returns
    an empty string if the file is not found. If no path
    is supplied, just finds the first file with that name
    in the dbfs (useful for media files, which have unique names)
    """
    s = ""
    if path != "":
        r = db.query_tuple(
            dbo, "SELECT Content FROM dbfs WHERE Name = '%s' AND Path = '%s'" %
            (name, path))
        if len(r) > 0 and len(r[0]) > 0:
            s = r[0][0]
    else:
        r = db.query_tuple(dbo,
                           "SELECT Content FROM dbfs WHERE Name = '%s'" % name)
        if len(r) > 0 and len(r[0]) > 0:
            s = r[0][0]
    if s != "":
        try:
            s = base64.b64decode(s)
        except:
            em = str(sys.exc_info()[0])
            al.error(
                "Failed unpacking path=%s, name=%s: %s" % (path, name, em),
                "dbfs.get_string", dbo)
            s = ""
    return s
Example #2
0
def get_string(dbo, name, path = ""):
    """
    Gets DBFS file contents as a string. Returns
    an empty string if the file is not found. If no path
    is supplied, just finds the first file with that name
    in the dbfs (useful for media files, which have unique names)
    """
    s = ""
    if path != "":
        r = db.query_tuple(dbo, "SELECT Content FROM dbfs WHERE Name = '%s' AND Path = '%s'" % (name, path))
        if len(r) > 0 and len(r[0]) > 0:
            s = r[0][0]
    else:
        r = db.query_tuple(dbo, "SELECT Content FROM dbfs WHERE Name = '%s'" % name)
        if len(r) > 0 and len(r[0]) > 0:
            s = r[0][0]
    if s != "":
        try:
            s = base64.b64decode(s)
        except:
            em = str(sys.exc_info()[0])
            al.error("Failed unpacking path=%s, name=%s: %s" % (path, name, em), "dbfs.get_string", dbo)
            s = ""
    return s
Example #3
0
def get_string_id(dbo, dbfsid):
    """
    Gets DBFS file contents as a string. Returns
    an empty string if the file is not found.
    """
    s = ""
    r = db.query_tuple(dbo, "SELECT Content FROM dbfs WHERE ID = '%d'" % dbfsid)
    if len(r) > 0 and len(r[0]) > 0:
        s = r[0][0]
    if s != "":
        try:
            s = base64.b64decode(s)
        except:
            em = str(sys.exc_info()[0])
            al.error("Failed unpacking id=%d: %s" % (dbfsid, em), "dbfs.get_string_id", dbo)
            s = ""
    return s
Example #4
0
def get_string_id(dbo, dbfsid):
    """
    Gets DBFS file contents as a string. Returns
    an empty string if the file is not found.
    """
    s = ""
    r = db.query_tuple(dbo,
                       "SELECT Content FROM dbfs WHERE ID = '%d'" % dbfsid)
    if len(r) > 0 and len(r[0]) > 0:
        s = r[0][0]
    if s != "":
        try:
            s = base64.b64decode(s)
        except:
            em = str(sys.exc_info()[0])
            al.error("Failed unpacking id=%d: %s" % (dbfsid, em),
                     "dbfs.get_string_id", dbo)
            s = ""
    return s