/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2015-05-25 07:54:07 UTC
  • mto: This revision was merged to the branch mainline in revision 756.
  • Revision ID: teddy@recompile.se-20150525075407-x7u0z4f1zej6bm87
mandos (subprocess_call_pipe): Rename to "call_pipe" and take "func".

Generalize "subprocess_call_pipe" to "call_pipe" which takes an
additional "func" argument which is the function to be run.

Show diffs side-by-side

added added

removed removed

Lines of Context:
423
423
            .format(self.name)))
424
424
        return ret
425
425
 
426
 
def subprocess_call_pipe(connection, # : multiprocessing.Connection
427
 
                         *args, **kwargs):
 
426
def call_pipe(connection,       # : multiprocessing.Connection
 
427
              func, *args, **kwargs):
428
428
    """This function is meant to be called by multiprocessing.Process
429
429
    
430
 
    This function runs a synchronous subprocess.call(), and writes the
431
 
    resulting return code on the provided multiprocessing.Connection.
 
430
    This function runs func(*args, **kwargs), and writes the resulting
 
431
    return value on the provided multiprocessing.Connection.
432
432
    """
433
 
    connection.send(subprocess.call(*args, **kwargs))
 
433
    connection.send(func(*args, **kwargs))
434
434
    connection.close()
435
435
 
436
436
class Client(object):
650
650
        """The checker has completed, so take appropriate actions."""
651
651
        self.checker_callback_tag = None
652
652
        self.checker = None
653
 
        # Read return code from connection (see subprocess_call_pipe)
 
653
        # Read return code from connection (see call_pipe)
654
654
        returncode = connection.recv()
655
655
        connection.close()
656
656
        
742
742
                                   "stderr": wnull })
743
743
            pipe = multiprocessing.Pipe(duplex=False)
744
744
            self.checker = multiprocessing.Process(
745
 
                target=subprocess_call_pipe, args=(pipe[1], command),
746
 
                kwargs=popen_args)
 
745
                target = call_pipe,
 
746
                args = (subprocess.call, pipe[1], command),
 
747
                kwargs = popen_args)
747
748
            self.checker.start()
748
749
            self.checker_callback_tag = gobject.io_add_watch(
749
750
                pipe[0].fileno(), gobject.IO_IN,