Returns a new tshark process with previously-set parameters.
359476
async def _get_tshark_process(self, packet_count=None, stdin=None):
        
        if self.use_json:
            output_type = 'json'
            if not tshark_supports_json(self.tshark_path):
                raise TSharkVersionException("JSON only supported on Wireshark >= 2.2.0")
        else:
            output_type = 'psml' if self._only_summaries else 'pdml'
        parameters = [self._get_tshark_path(), '-l', '-n', '-T', output_type] + \
            self.get_parameters(packet_count=packet_count)

        self._log.debug('Creating TShark subprocess with parameters: ' + ' '.join(parameters))
        self._log.debug('Executable: %s' % parameters[0])
        tshark_process = await asyncio.create_subprocess_exec(*parameters,
                                                              stdout=subprocess.PIPE,
                                                              stderr=self._stderr_output(),
                                                              stdin=stdin)
        self._created_new_process(parameters, tshark_process)
        return tshark_process
829415
async def packets_from_tshark(self, packet_callback, packet_count=None, close_tshark=True):
        
        tshark_process = await self._get_tshark_process(packet_count=packet_count)
        try:
            await self._go_through_packets_from_fd(tshark_process.stdout, packet_callback, packet_count=packet_count)
        except StopCapture:
            pass
        finally:
            if close_tshark:
                await self._close_async()
854248
def create_warn_fork_exec(original_name):
    

    def new_warn_fork_exec(*args):
        try:
            import _posixsubprocess
            warn_multiproc()
            return getattr(_posixsubprocess, original_name)(*args)
        except:
            pass

    return new_warn_fork_exec
240488
def project_new(input_params={}, always_retry=False, **kwargs):
    
    return DXHTTPRequest('/project/new', input_params, always_retry=always_retry, **kwargs)
676548
def create_new(cls, oldvalue, *args):
    ""
    if oldvalue is not None:
        raise AlreadyExistsException('%r already exists' % (oldvalue,))
    return cls.create_instance(*args)
8564
public static <T> TimestampedValue<T> from(StreamRecord<T> streamRecord) {
		if (streamRecord.hasTimestamp()) {
			return new TimestampedValue<>(streamRecord.getValue(), streamRecord.getTimestamp());
		} else {
			return new TimestampedValue<>(streamRecord.getValue());
		}
	}
459026
private Object createSharedProcessInstance()   {
		ProxyFactory proxyFactoryBean = new ProxyFactory(ProcessInstance.class, new MethodInterceptor() {
			public Object invoke(MethodInvocation methodInvocation) throws Throwable {
				String methodName = methodInvocation.getMethod().getName() ;

				logger.info("method invocation for " + methodName+ ".");
				if(methodName.equals("toString"))
					return "SharedProcessInstance";


				ProcessInstance processInstance = Context.getExecutionContext().getProcessInstance();
				Method method = methodInvocation.getMethod();
				Object[] args = methodInvocation.getArguments();
				Object result = method.invoke(processInstance, args);
				return result;
			}
		});
		return proxyFactoryBean.getProxy(this.classLoader);
	}
92418
def new_encoded_stream(args, stream):
    ''''''
    if args.ascii_print:
        return wpull.util.ASCIIStreamWriter(stream)
    else:
        return stream
90405
def spawn_process(self, port):
        
        return process.Process(name="ServerProcess.%i" % port,
                               kwargs={'namespace': self.namespace,
                                       'port': port})
404766
def _new_stream(self, idx):
        '''
        '''
        # instantiate
        if self.rate is not None:
            n_stream = 1 + self.rng.poisson(lam=self.rate)
        else:
            n_stream = None

        # If we're sampling without replacement, zero this one out
        # This effectively disables this stream as soon as it is chosen,
        # preventing it from being chosen again (unless it is revived)
        if not self.with_replacement:
            self.distribution_[idx] = 0.0

            # Correct the distribution
            if (self.distribution_ > 0).any():
                self.distribution_[:] /= np.sum(self.distribution_)

        return (self.streamers[idx].iterate(max_iter=n_stream),
                self.weights[idx])
182460
def tdecode(pkt, *args):
    """"""
    if not args:
      args = [ "-V" ]
    fname = get_temp_file()
    wrpcap(fname,[pkt])
    subprocess.call(["tshark", "-r", fname] + list(args))
44718
def spawn_new(self, key):
        """"""
        # Check if path exists
        if not os.path.exists(self.queue[key]['path']):
            self.queue[key]['status'] = 'failed'
            error_msg = "The directory for this command doesn't exist anymore: {}".format(self.queue[key]['path'])
            self.logger.error(error_msg)
            self.queue[key]['stdout'] = ''
            self.queue[key]['stderr'] = error_msg

        else:
            # Get file descriptors
            stdout, stderr = self.get_descriptor(key)

            if self.custom_shell != 'default':
                # Create subprocess
                self.processes[key] = subprocess.Popen(
                    [
                        self.custom_shell,
                        '-i',
                        '-c',
                        self.queue[key]['command'],
                    ],
                    stdout=stdout,
                    stderr=stderr,
                    stdin=subprocess.PIPE,
                    universal_newlines=True,
                    preexec_fn=os.setsid,
                    cwd=self.queue[key]['path']
                )
            else:
                # Create subprocess
                self.processes[key] = subprocess.Popen(
                    self.queue[key]['command'],
                    shell=True,
                    stdout=stdout,
                    stderr=stderr,
                    stdin=subprocess.PIPE,
                    universal_newlines=True,
                    preexec_fn=os.setsid,
                    cwd=self.queue[key]['path']
                )
            self.queue[key]['status'] = 'running'
            self.queue[key]['start'] = str(datetime.now().strftime("%H:%M"))

        self.queue.write()
505521
def create(doc=None, error_text=None, exception_handlers=empty.dict, extend=Type, chain=True, auto_instance=True,
           accept_context=False):
    """"""
    extend = extend if type(extend) == type else type(extend)

    def new_type_handler(function):
        class NewType(extend):
            __slots__ = ()
            _accept_context = accept_context

            if chain and extend != Type:
                if error_text or exception_handlers:
                    if not accept_context:
                        def __call__(self, value):
                            try:
                                value = super(NewType, self).__call__(value)
                                return function(value)
                            except Exception as exception:
                                for take_exception, rewrite in exception_handlers.items():
                                    if isinstance(exception, take_exception):
                                        if isinstance(rewrite, str):
                                            raise ValueError(rewrite)
                                        else:
                                            raise rewrite(value)
                                if error_text:
                                    raise ValueError(error_text)
                                raise exception
                    else:
                        if extend._accept_context:
                            def __call__(self, value, context):
                                try:
                                    value = super(NewType, self).__call__(value, context)
                                    return function(value, context)
                                except Exception as exception:
                                    for take_exception, rewrite in exception_handlers.items():
                                        if isinstance(exception, take_exception):
                                            if isinstance(rewrite, str):
                                                raise ValueError(rewrite)
                                            else:
                                                raise rewrite(value)
                                    if error_text:
                                        raise ValueError(error_text)
                                    raise exception
                        else:
                            def __call__(self, value, context):
                                try:
                                    value = super(NewType, self).__call__(value)
                                    return function(value, context)
                                except Exception as exception:
                                    for take_exception, rewrite in exception_handlers.items():
                                        if isinstance(exception, take_exception):
                                            if isinstance(rewrite, str):
                                                raise ValueError(rewrite)
                                            else:
                                                raise rewrite(value)
                                    if error_text:
                                        raise ValueError(error_text)
                                    raise exception
                else:
                    if not accept_context:
                        def __call__(self, value):
                            value = super(NewType, self).__call__(value)
                            return function(value)
                    else:
                        if extend._accept_context:
                            def __call__(self, value, context):
                                value = super(NewType, self).__call__(value, context)
                                return function(value, context)
                        else:
                            def __call__(self, value, context):
                                value = super(NewType, self).__call__(value)
                                return function(value, context)
            else:
                if not accept_context:
                    if error_text or exception_handlers:
                        def __call__(self, value):
                            try:
                                return function(value)
                            except Exception as exception:
                                for take_exception, rewrite in exception_handlers.items():
                                    if isinstance(exception, take_exception):
                                        if isinstance(rewrite, str):
                                            raise ValueError(rewrite)
                                        else:
                                            raise rewrite(value)
                                if error_text:
                                    raise ValueError(error_text)
                                raise exception
                    else:
                        def __call__(self, value):
                            return function(value)
                else:
                    if error_text or exception_handlers:
                        def __call__(self, value, context):
                            try:
                                return function(value, context)
                            except Exception as exception:
                                for take_exception, rewrite in exception_handlers.items():
                                    if isinstance(exception, take_exception):
                                        if isinstance(rewrite, str):
                                            raise ValueError(rewrite)
                                        else:
                                            raise rewrite(value)
                                if error_text:
                                    raise ValueError(error_text)
                                raise exception
                    else:
                        def __call__(self, value, context):
                            return function(value, context)

        NewType.__doc__ = function.__doc__ if doc is None else doc
        if auto_instance and not (introspect.arguments(NewType.__init__, -1) or
                                  introspect.takes_kwargs(NewType.__init__) or
                                  introspect.takes_args(NewType.__init__)):
            return NewType()
        return NewType

    return new_type_handler
116030
def new(self, *args, **kwargs):
        '''
'''
        return self.session().add(self.model(*args, **kwargs))
1313197
def bg_process(func):
    
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        p = multiprocessing.Process(target=func, args=args, kwargs=kwargs)
        p.start()
    return wrapper
225887
def create_CreateProcessWarnMultiproc(original_name):
    

    def new_CreateProcess(*args):
        try:
            import _subprocess
        except ImportError:
            import _winapi as _subprocess
        warn_multiproc()
        return getattr(_subprocess, original_name)(*args)

    return new_CreateProcess
537155
def new(cls, gen: Generator, sign_key: SignKey) -> 'VerKey':
        
        logger = logging.getLogger(__name__)
        logger.debug("VerKey::new: >>>")

        c_instance = c_void_p()
        do_call(cls.new_handler, gen.c_instance, sign_key.c_instance, byref(c_instance))

        res = cls(c_instance)

        logger.debug("VerKey::new: <<< res: %r", res)
        return res