Ejemplo n.º 1
0
    def wait(self):
        """ Wait for asynchronous subprocess to exit
        
        Args:
            None
            
        Returns:
            list of result strings
            
        Raises:
            CommandStateError when no subprocess is active    
        """
        #--

        if (self.proc is None):
            raise CommandStateError()

        try:
            self.proc.wait()
            retcode = self.proc.returncode
            msgs = self._format_result(retcode, None, None)
            del self.proc
            self.proc = None
            return msgs
        except Exception as e:
            raise CommandError(ExceptionHandler.format_exception(e))
Ejemplo n.º 2
0
    def async (self, cmd):
        """ Execute subprocess asynchronously
        
        Args:
            cmd (string): shell command to execute
           
        Returns:
            None
            
        Raises:
            see sync method above.
                
        Notes:
            see sync method above. 
        """
        #--
        if (isinstance(cmd, str)):
            shell_mode = True
        elif (isinstance(cmd, (list, tuple))):
            shell_mode = False
        else:
            raise CommandParameterError(self.name, 'cmd', cmd)

        try:
            self.proc = subprocess.Popen(cmd,
                                         shell=shell_mode,
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE)
        except Exception as e:
            raise CommandError(ExceptionHandler.format_exception(e))
Ejemplo n.º 3
0
 def wait(self):
     """ Wait for asynchronous subprocess to exit
     
     Args:
         None
         
     Returns:
         list of result strings
         
     Raises:
         CommandStateError when no subprocess is active    
     """
     #--
     
     if (self.proc is None):
         raise CommandStateError()
     
     try:
         self.proc.wait()
         retcode = self.proc.returncode  
         msgs = self._format_result(retcode, None, None)
         del self.proc
         self.proc = None
         return msgs
     except Exception as e:
         raise CommandError(ExceptionHandler.format_exception(e))
Ejemplo n.º 4
0
    def sync(self, cmd):
        """ Execute subprocess synchronously
        
        Args:
            cmd (string): shell command to execute
            cmd (list):   command arguments to pass
                
        Returns:
            A list of strings:
                ['retcode' : 0,
                 'output' : '...',
                 'errors' : '...'
                 ]
                 
        Raises:
            CommandParameterError when command is not a string type
                
        Notes:
            Shell command  is a string like "cd tmp && ls".
            Command arguments is a list like ['gedit', 'file1', file2',...]
            Output and errors strings are only returned to the caller
            when the subprocess returns output or errors.
        """
        #--
        if (ut.is_string_type(cmd)):
            shellmode = True
        elif (isinstance(cmd, (list, tuple))):
            shellmode = False
        else:
            raise CommandParameterError('cmd', cmd)

        try:
            self.proc = subprocess.Popen(cmd,
                                         shell=shellmode,
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE)
            bstdout, bstderr = self.proc.communicate()
            retcode = self.proc.returncode
            self.proc.stdout.close()
            self.proc.stderr.close()
            self.proc = None
            return self._format_result(retcode, bstdout, bstderr)
        except Exception as e:
            raise CommandError(ExceptionHandler.format_exception(e))
Ejemplo n.º 5
0
 def sync(self, cmd):
     """ Execute subprocess synchronously
     
     Args:
         cmd (string): shell command to execute
         cmd (list):   command arguments to pass
             
     Returns:
         A list of strings:
             ['retcode' : 0,
              'output' : '...',
              'errors' : '...'
              ]
              
     Raises:
         CommandParameterError when command is not a string type
             
     Notes:
         Shell command  is a string like "cd tmp && ls".
         Command arguments is a list like ['gedit', 'file1', file2',...]
         Output and errors strings are only returned to the caller
         when the subprocess returns output or errors.
     """
     #--
     if (ut.is_string_type(cmd)):
         shellmode = True
     elif (isinstance(cmd, (list,tuple))):
         shellmode = False
     else:
         raise CommandParameterError('cmd', cmd)
     
     try:
         self.proc = subprocess.Popen(cmd,
                                      shell=shellmode,
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.PIPE)
         bstdout, bstderr = self.proc.communicate()
         retcode = self.proc.returncode
         self.proc.stdout.close()
         self.proc.stderr.close()
         self.proc = None      
         return self._format_result(retcode, bstdout, bstderr)
     except Exception as e:
         raise CommandError(ExceptionHandler.format_exception(e))
Ejemplo n.º 6
0
    check_patch("capes/0008-capemgr-Priority-on-capemgr.enable_partno-option.patch",
                "quilt/checks/check_capes_0008.tmp", { "mode" : "complete" })

def reset_quilt():
    ''' Reset quilt. This must be done each time you start from the first patch.
        Our local copy of the first patch was modified from '--- /dev/null' to
        '--- drivers/.../capemgr.c' to allow this to work.
        '''
    h.cmd("echo \'\' > ./quilt/drivers/misc/cape/beaglebone/capemgr.c")
    h.cmd("echo \'\' > ./quilt/.pc/applied-patches")
        
if __name__ == '__main__':
    
    global c, h
    
    exception_handler = ExceptionHandler()
    
    try:
        
        h = Helper('config.json')
        c = h.config
    
        find_patch_refs()
        
        '''
        # In this section we alternate between applying patches and matching
        # the result against the next patch:
        
        reset_quilt()
        apply_patch()   # Apply not-capebus/0030