Exemplo n.º 1
0
    def from_git_hash(self, githash):
        import subprocess
        import tarfile
        from cStringIO import StringIO
        #
        # Grab the exact uavo definition files from the git repo using the header's git hash
        #
        p = subprocess.Popen(
            ['git', 'archive', githash, '--', 'shared/uavobjectdefinition/'],
            stdout=subprocess.PIPE)
        # grab the tar file data
        git_archive_data, git_archive_errors = p.communicate()

        # coerce the tar file data into a file object so that tarfile likes it
        fobj = StringIO(git_archive_data)

        # feed the tar file data to a tarfile object
        t = tarfile.open(fileobj=fobj)

        # Build up the uavo definitions for all of the available UAVO at this git hash
        for f_info in t.getmembers():
            if not f_info.isfile():
                continue

            f = t.extractfile(f_info)

            u = uavo.make_class(f)

            # add this uavo definition to our dictionary
            self.update([('{0:08x}'.format(u._id), u)])
Exemplo n.º 2
0
    def from_git_hash(self, githash):
        import subprocess
        import tarfile
        from cStringIO import StringIO
        #
        # Grab the exact uavo definition files from the git repo using the header's git hash
        #
        p = subprocess.Popen(['git', 'archive', githash, '--', 'shared/uavobjectdefinition/'],
                             stdout=subprocess.PIPE)
        # grab the tar file data
        git_archive_data, git_archive_errors = p.communicate()

        # coerce the tar file data into a file object so that tarfile likes it
        fobj = StringIO(git_archive_data)

        # feed the tar file data to a tarfile object
        t = tarfile.open(fileobj=fobj)

        # Build up the uavo definitions for all of the available UAVO at this git hash
        for f_info in t.getmembers():
            if not f_info.isfile():
                continue

            f = t.extractfile(f_info)

            u = uavo.make_class(f)

            # add this uavo definition to our dictionary
            self.update([('{0:08x}'.format(u._id), u)])
Exemplo n.º 3
0
    def from_file_contents(self, content_list):
        some_processed = True

        # There are dependencies here
        while some_processed:
            some_processed = False

            unprocessed = []

            # Build up the UAV objects from the xml definitions
            for contents in content_list:
                try:
                    u = uavo.make_class(self, contents)

                    # add this uavo definition to our dictionary
                    self.update([('{0:08x}'.format(u._id), u)])

                    some_processed = True
                except Exception:
                    unprocessed.append(contents)

            content_list = unprocessed

        if len(content_list):
            raise Exception("Unable to parse some uavo files")
Exemplo n.º 4
0
    def from_uavo_xml_path(self, path):
        import os
        import glob

        for file_name in glob.glob(os.path.join(path, '*.xml')):
            with open(file_name, 'rU') as f:
                u = uavo.make_class(f)

                # add this uavo definition to our dictionary
                self.update([('{0:08x}'.format(u._id), u)])
Exemplo n.º 5
0
    def from_uavo_xml_path(self, path):
        import os
        import glob

        for file_name in glob.glob(os.path.join(path, '*.xml')):
            with open(file_name, 'rU') as f:
                u = uavo.make_class(f)

                # add this uavo definition to our dictionary
                self.update([('{0:08x}'.format(u._id), u)])
Exemplo n.º 6
0
    def from_uavo_xml_path(self, path):
        import os
        import glob

        # Make sure the shared definitions are parsed first
        file_names = []
        for file_name in glob.glob(os.path.join(path, '*.xml')):
            if op.basename(file_name).lower().find('shared') > 0:
                file_names.insert(0, file_name)
            else:
                file_names.append(file_name)

        for file_name in file_names:
            with open(file_name, 'rU') as f:
                u = uavo.make_class(self, f)

                # add this uavo definition to our dictionary
                self.update([('{0:08x}'.format(u._id), u)])
Exemplo n.º 7
0
    def from_uavo_xml_path(self, path):
        import os
        import glob

        # Make sure the shared definitions are parsed first
        file_names = []
        for file_name in glob.glob(os.path.join(path, '*.xml')):
            if op.basename(file_name).lower().find('shared') > 0:
                file_names.insert(0, file_name)
            else:
                file_names.append(file_name)

        for file_name in file_names:
            with open(file_name, 'rU') as f:
                u = uavo.make_class(self, f)

                # add this uavo definition to our dictionary
                self.update([('{0:08x}'.format(u._id), u)])
Exemplo n.º 8
0
    def from_git_hash(self, githash):
        import subprocess
        import tarfile
        from cStringIO import StringIO
        # Get the directory where the Tau Labs code is located
        tl_dir = op.join(op.dirname(__file__), "..", "..")
        #
        # Grab the exact uavo definition files from the git repo using the header's git hash
        #
        p = subprocess.Popen(
            ['git', 'archive', githash, '--', 'shared/uavobjectdefinition/'],
            stdout=subprocess.PIPE,
            cwd=tl_dir)
        # grab the tar file data
        git_archive_data, git_archive_errors = p.communicate()

        # coerce the tar file data into a file object so that tarfile likes it
        fobj = StringIO(git_archive_data)

        # feed the tar file data to a tarfile object
        t = tarfile.open(fileobj=fobj)

        # Get the file members
        f_members = []
        for f_info in t.getmembers():
            if not f_info.isfile():
                continue
            # Make sure the shared definitions are parsed first
            if op.basename(f_info.name).lower().find('shared') > 0:
                f_members.insert(0, f_info)
            else:
                f_members.append(f_info)

        # Build up the UAV objects from the xml definitions
        for f_info in f_members:
            f = t.extractfile(f_info)

            u = uavo.make_class(self, f)

            # add this uavo definition to our dictionary
            self.update([('{0:08x}'.format(u._id), u)])
Exemplo n.º 9
0
    def from_git_hash(self, githash):
        import subprocess
        import tarfile
        from cStringIO import StringIO
        # Get the directory where the Tau Labs code is located
        tl_dir = op.join(op.dirname(__file__), "..", "..")
        #
        # Grab the exact uavo definition files from the git repo using the header's git hash
        #
        p = subprocess.Popen(['git', 'archive', githash, '--', 'shared/uavobjectdefinition/'],
                             stdout=subprocess.PIPE, cwd=tl_dir)
        # grab the tar file data
        git_archive_data, git_archive_errors = p.communicate()

        # coerce the tar file data into a file object so that tarfile likes it
        fobj = StringIO(git_archive_data)

        # feed the tar file data to a tarfile object
        t = tarfile.open(fileobj=fobj)

        # Get the file members
        f_members = []
        for f_info in t.getmembers():
            if not f_info.isfile():
                continue
            # Make sure the shared definitions are parsed first
            if op.basename(f_info.name).lower().find('shared') > 0:
                f_members.insert(0, f_info)
            else:
                f_members.append(f_info)

        # Build up the UAV objects from the xml definitions
        for f_info in f_members:
            f = t.extractfile(f_info)

            u = uavo.make_class(self, f)

            # add this uavo definition to our dictionary
            self.update([('{0:08x}'.format(u._id), u)])
Exemplo n.º 10
0
    def from_tar_file(self, t):
        # Get the file members
        f_members = []
        for f_info in t.getmembers():
            if not f_info.isfile():
                continue
            # Make sure the shared definitions are parsed first
            if op.basename(f_info.name).lower().find('shared') > 0:
                f_members.insert(0, f_info)
            else:
                f_members.append(f_info)

        # Build up the UAV objects from the xml definitions
        for f_info in f_members:
            if f_info.name.count("oplinksettings") > 0:
                continue

            f = t.extractfile(f_info)

            u = uavo.make_class(self, f)

            # add this uavo definition to our dictionary
            self.update([('{0:08x}'.format(u._id), u)])