Пример #1
0
def fetch_sources():
    # Validate that we are cloning into correct directory
    verification_file = system.current_path() + "/src-files/is_correct_file"
    verification_source = system.current_path() + "/src-files/.sources_exist"

    if system.is_file(verification_file):
        first_buffer = system.readf(verification_file)
        # Is correct file
        if not first_buffer.find("true"):
            raise Exception("\n\tPoky-build verification failed\n")
    # Not in correct directory
    else:
        raise Exception("\n\tThis command should be executed within the "
                        "root directory of poky clone.\n"
                        "\trun: 'src fetch poky' before "
                        "executing this command\n")

    # Validate whether previous sources exists
    if system.is_file(verification_source) is False:
        print("\n\tSources already exists. Proceeding without "
              "fetching the new sources")
        return

    # Initialize the process
    print("Initializing process to fetch meta-data\n")
Пример #2
0
def fix_filename(f, encoding=None):
    if system.is_file(f):
        return f
    if type(f) is unicode:
        encodings = ['latin1', 'utf-8', ENCODING]
        if encoding:
            encodings = [encoding] + encodings
        for encoding in encodings:
            try:
                f = f.encode(encoding)
                if system.is_file(f):
                    return f
            except UnicodeEncodeError:
                pass
    return None
Пример #3
0
 def to_python(self, x, label, test=False):
     value = super(ReadFileField, self).to_python(x, label)
     if not value.strip() and self.allow_empty:
         return ''
     if (x == value or not test) and (not system.is_file(value)):
         raise ValidationError(self.description,
         '%s: %s.' % (_(label),
             _('the filename "%s" does not exist') % value))
     return value
Пример #4
0
 def to_python(self, x, label, test=False):
     value = super(ReadFileField, self).to_python(x, label)
     if not value.strip() and self.allow_empty:
         return ''
     if (x == value or not test) and (not system.is_file(value)):
         raise ValidationError(
             self.description, '%s: %s.' %
             (_(label), _('the filename "%s" does not exist') % value))
     return value
Пример #5
0
def config_check():
	import system
	import os
	import yaml

	config_dir = system.current_path() + "/ccbuild-files"
	config_file = config_dir + "/ccbuild_config.yaml"
	if not system.is_dir(config_dir):
		print("Creating ccbuild-files directory at", config_dir)
		os.mkdir(config_dir)
		return
	else:
		if not system.is_file(config_file):
			print("Generating ccbuild_config.yaml in configuration directory")
			file = open(config_file, "w+")
			file.close()
		else:
			config_data = open(config_file)
			parsed = yaml.load(config_data, Loader=yaml.FullLoader)
			return parsed.get("fetch")