Esempio n. 1
0
def handle_jpeg(year: int, day: int, filename: Text) -> flask.Response:
  name = urllib.parse.unquote(flask.request.path)
  manager = site_manager.SiteManager(name)
  img = manager.cloud_mask_jpeg()
  response = flask.make_response(img)
  response.headers.set('Content-Type', 'image/jpeg')
  return response  
Esempio n. 2
0
def get_local_verilog_path_dict():
    sm = site_manager.SiteManager()
    package_names = sm.get_local_verilog_package_names()
    vpackage_dict = {}
    for pname in package_names:
        vpackage_dict[pname] = sm.get_local_verilog_package_path(pname)

    return vpackage_dict
Esempio n. 3
0
def handle_gif(year: int, month: int, day: int, filename: Text) -> flask.Response:
  name = urllib.parse.unquote(flask.request.path)
  manager = site_manager.SiteManager(name)
  logging.info('Fetching %s', name)
  img = manager.animated_gif()
  response = flask.make_response(img)
  response.headers.set('Content-Type', 'image/gif')
  return response  
Esempio n. 4
0
def get_local_verilog_paths():
    sm = site_manager.SiteManager()
    temp_dirs = sm.get_local_verilog_paths()
    local_dirs = []

    package_names = sm.get_local_verilog_package_names()
    for d in temp_dirs:
        if os.path.exists(os.path.join(d, "verilog")):
            local_dirs.append(os.path.join(d, "verilog"))
        else:
            local_dirs.append(d)

    return list(set(local_dirs))
Esempio n. 5
0
def install_remote_board_package(board_name, status = None):
    sm = site_manager.SiteManager()
    s = status
    if s: s.Warning("Could not find %s on local host" % board_name)
    if not sm.remote_board_exists(board_name):
        if s: s.Fatal("Could not find %s in remote board table" % board_name)
        raise IBuilderError("Could not find board %s on local host, checked remote board table" % board_name)

    if s: s.Verbose("Found %s on the remote server" % board_name)

    board_path = os.path.join(site_manager.get_board_package_path(), board_name)
    if s: s.Important("Installing %s to %s" % (board_name, site_manager.get_board_package_path()))
    sm.install_remote_board_package(board_name)
Esempio n. 6
0
def get_board_names (user_paths = [], debug = False):
    """Returns a list of all the board names"""
    sm = site_manager.SiteManager()
    #Get the installed board locations
    boards = sm.get_local_board_names()

    #Check user paths
    board_locations = user_paths
    for bl in board_locations:
        for root, dirs, names in os.walk(bl):
            if debug: print "Dirs: " + str(dirs)
            for bn in dirs:
                boards.append(bn)

    return boards
Esempio n. 7
0
def get_nysa_user_base():
    """Returns the path to Nysa user base. This is the directory where the user
    generally puts all their files

    Args:
        Nothing

    Returns (String):
        absolute path to the user base directory

    Raises:
        SiteManagerError: Errors associated with site manager
    """
    sm = site_manager.SiteManager()
    return sm.get_nysa_user_base_directory()
Esempio n. 8
0
def get_constraint_filenames (board_name, user_paths = [], debug = False):
    """Returns a list of ucf files for the specified board name"""
    #board_dir = os.path.join(nysa_base, "ibuilder", "boards", board_name)
    sm = site_manager.SiteManager()
    board_location = None
    cfiles = []

    try:
        board_location = get_board_directory(board_name)
        config_dict = get_board_config(board_name, user_paths, debug = debug)
        if "default_constraint_files" in config_dict:
            for cf in config_dict["default_constraint_files"]:
                cfiles.append(os.path.join(board_location, board_name, "board", cf))

    except site_manager.SiteManagerError as ex:
        if debug: print "%s is not in the installed path, checking user paths..." % board_name

    #board_locations = [board_dir]
    #board_locations.extend(user_paths)
    board_locations = user_paths

    for bl in board_locations:
        if debug: print "Board dir: %s" % bl
        for root, dirs, names in os.walk(bl):
            if debug:
                print "names: " + str(names)

            for name in names:
                s = name.partition(".")[2].lower()

                if debug:
                    print "last: " + s
                if s == "ucf":
                    cfiles.append(name)
                    if debug:
                        print "constraint file: %s" % name

    return cfiles
Esempio n. 9
0
def install_local_board_package(board_name, path, run_platform_setup, status = None):
    sm = site_manager.SiteManager(status)
    sm.install_local_board_package(board_name, path, run_platform_setup)
Esempio n. 10
0
def update_verilog_package(name = None, branch = None):
    sm = site_manager.SiteManager()
    sm.update_verilog_package(name, branch)
Esempio n. 11
0
def get_local_verilog_path(name):
    sm = site_manager.SiteManager()
    package_names = sm.get_local_verilog_package_names()
    if name.lower() not in package_names:
        raise IBuilderError("Verilog package %s not found!", name)
    return sm.get_local_verilog_package_path(name.lower())
Esempio n. 12
0
def clean_verilog_package_paths():
    sm = site_manager.SiteManager()
    sm.clean_verilog_package_paths()
Esempio n. 13
0
def get_board_config (board_name, user_paths = [], debug = False):
    """Returns a dictionary of board specific information

    Args:
        board_name: the name of the board to get the information from
            Example: \"sycamore1\"

    Returns:
        A dictionary of the board configuration data

    Raises:
        Nothing
    """
    sm = site_manager.SiteManager()
    board_location = None
    bn = str(board_name).lower()
    try:
        board_location = get_board_directory(board_name)
    except site_manager.SiteManagerError as ex:
        if debug: print "%s is not in the installed path, checking user paths..." % board_name
        pass

    if board_location is None:
        board_locations = user_paths

        filename = ""
        buf = ""
        config_dict = {}

        if debug: print "Looking for: " + board_name
        final_path = None

        for bl in board_locations:
            for root, dirs, names in os.walk(bl):
                if debug: print "Dirs: " + str(dirs)
                if board_name in dirs:
                    if debug: print "Found the directory"
                    final_path = os.path.join(root)
                    filename = os.path.join(root, bn, "board", "config.json")
                    if os.path.exists(filename):
                        if debug: print "filename: %s" % filename
                        break

        if len(filename) == 0:
            if debug: print "didn't find board config file"
            return {}

        board_location = final_path

    else:
        filename = os.path.join(board_location, bn, "board", "config.json")

    #open up the config file
    file_in = open(filename)
    buf = file_in.read()
    config_dict = json.loads(buf)
    file_in.close()

    if debug:
        print "Opened up the board config file for %s" % (board_name)

    #Create absolute references to any files within the board config files
    if "default_constraint_files" in config_dict:
        #Create absolute references to any filenames declared
        filenames = config_dict["default_constraint_files"]
        abs_filenames = []
        path = os.path.join(board_location, bn, "board")
        if debug: print "Path: %s" % str(path)
        for filename in filenames:
            if not os.path.exists(filename):
                if ("/" in filename) or ("\\" in filename):
                    path_list = []
                    if "/" in filename:
                        path_list = filename.split("/")
                    else:
                        path_list = filename.split("\\")

                    filename = path
                    for p in path_list:
                        filename = os.path.join(filename, p)
                else:
                    filename = os.path.join(path, filename)

                filename = os.path.abspath(filename)

            abs_filenames.append(filename)

        config_dict["default_constraint_files"] = abs_filenames

    if debug: print "Looking for a parent board"
    if "parent_board" in config_dict:
        if debug: print "Found a reference to parent!"
        for parent in config_dict["parent_board"]:
            if debug: print "Parent: %s" % parent
            parent_config = get_board_config(parent, user_paths, debug = debug)
            for key in parent_config:
                if debug: print "Looking at key: %s" % key
                if key not in config_dict:
                    if debug: print "\tKey not in child dict, inserting..."
                    config_dict[key] = parent_config[key]
                if isinstance(config_dict[key], list):
                    if debug: print "\tFound a list, appending values..."
                    config_dict[key] += parent_config[key]
                    if debug: print "\tNew list: %s" % str(config_dict[key])

            if "required" in parent_config:
                #print "Found a required in config dict"
                filepath = get_board_directory(parent)
                filepath = os.path.join(filepath, parent, "board", parent_config["required"])
                f = open(filepath, 'r')
                required = json.load(f)
                f.close()
                for key in required:
                    #print "Found a required entry: %s" % key
                    if key not in config_dict:
                        config_dict[key] = required[key]
                    elif isinstance(config_dict[key], list):
                        config_dict[key] += required[key]
                    elif isinstance(config_dict[key], dict):
                        for k in required[key]:
                            config_dict[key][k] = parent_config[key][k]

                        
    if "required" in config_dict:
        #print "Found a required in config dict"
        filepath = os.path.join(board_location, bn, "board", config_dict["required"])
        f = open(filepath, 'r')
        required = json.load(f)
        f.close()
        for key in required:
            #print "Found a required entry: %s" % key
            if key not in config_dict:
                config_dict[key] = required[key]
            elif isinstance(config_dict[key], list):
                config_dict[key] += required[key]
            elif isinstance(config_dict[key], dict):
                for k in required[key]:
                    if k not in config_dict[key]:
                        config_dict[key][k] = required[key][k]


    #for debug
    if "paths" not in config_dict:
        config_dict["paths"] = []

    config_dict["paths"].append(board_location)
    return config_dict
Esempio n. 14
0
def get_constraint_file_path(board_name, constraint_filename, user_paths = [], debug = False):
    """Gets the path of the constraint filename

    Args:
        board_name (String): name of the board to get the constraint name
        constraint_filename (String): name of a constraint file to find
        user_paths (String): list of user paths to add to the search directory


    Returns:
        (String) path to the constraint filename

    Raises:
        IBuilder Error
    """
    if os.path.exists(constraint_filename):
        return os.path.abspath(constraint_filename)

    board_name = board_name.lower()
    """Returns a list of ucf files for the specified board name"""
    #board_dir = os.path.join(nysa_base, "ibuilder", "boards", board_name)
    sm = site_manager.SiteManager()
    board_locations = []
    board_location = get_board_directory(board_name)

    try:
        if debug: print "Default board location found: %s" % board_location
        board_locations.append(board_location)
        config_dict = get_board_config(board_name, user_paths, debug = debug)
        if debug: print "Config Dict: %s" % str(config_dict)
        if "default_constraint_files" in config_dict:
            for cf in config_dict["default_constraint_files"]:
                if debug: print "Looking at constraint file: %s" % cf
                if constraint_filename == cf:
                    return os.path.join(board_location, board_name, "board", cf)

    except site_manager.SiteManagerError as ex:
        if debug: print "%s is not in the installed path, checking user paths..." % board_name

    board_dict = get_board_config(board_name)
    board_locations.extend(user_paths)
    if "parent_board" in board_dict:
        if debug: print "                 Parent Board!"
        for parent in board_dict["parent_board"]:
            board_dir = get_board_directory(parent)
            if debug: print "             Board Dir: %s" % str(board_dir)
            board_locations.append(board_dir)

    filename = ""
    buf = ""
    clock_rate = ""
    if debug: print "Looking for: %s in %s" % (constraint_filename, str(board_locations))
    for bl in board_locations:
        #if debug: print "board directory: %s" % str(bl)
        for root, dirs, names in os.walk(bl):
            #if debug: print "name: " + str(names)
            if constraint_filename in names:
                #if debug: print "found the file!"
                return os.path.join(root, constraint_filename)

            for d in dirs:
                pdir = os.path.join(root, d)
                filepath = _get_constraint_file_path(pdir, constraint_filename)
                if filepath is not None:
                    if debug: print "Found file: %s" % filepath
                    return filepath 
                    

    if (len(filename) == 0):
        verilog_dirs = get_local_verilog_paths()
        if debug: print "looking in verilog paths: %s" % str(verilog_dirs)
        for vd in verilog_dirs:
            for root, dirs, names in os.walk(vd):
                #if debug: print "name: " + str(names)
                if constraint_filename in names:
                    if debug: print "found the file: %s" % os.path.join(root, constraint_filename)
                    return os.path.join(root, constraint_filename)

    raise IBuilderError("Constraint File: %s wasn't found, looked in board directories and core directories" % constraint_filename)
Esempio n. 15
0
def get_user_dev_dir():
    sm = site_manager.SiteManager()
    return sm.get_user_dev_dir()
Esempio n. 16
0
def get_user_examples_dir():
    sm = site_manager.SiteManager()
    return sm.get_user_examples_dir()
Esempio n. 17
0
def board_exists(board_name):
    sm = site_manager.SiteManager()
    return sm.board_exists(board_name)
Esempio n. 18
0
def get_board_directory(board_name):
    return site_manager.SiteManager().get_board_directory(board_name)
Esempio n. 19
0
def get_user_verilog_dir():
    sm = site_manager.SiteManager()
    return sm.get_user_verilog_dir()
Esempio n. 20
0
def uninstall_local_board_package(board_name, status = None):
    sm = site_manager.SiteManager(status)
    sm.uninstall_local_board_package(board_name)
Esempio n. 21
0
def get_user_ibuilder_project_dir():
    sm = site_manager.SiteManager()
    return sm.get_user_ibuilder_project_dir()
Esempio n. 22
0
def index(year: int = 2019, month: int = 1, day: int = 1) -> Text:
  t = datetime.datetime(year, month, day)
  name = t.strftime('/%Y/%m/%d/index.html')
  manager = site_manager.SiteManager(name)
  return flask.render_template('index.html', date=t, site_manager=manager)