called rapidly by mavproxy
979369
def idle_task(self):
        ''''''
        if self.fix_type >= 3:
            # don't do anything if we have a fix
            return
        if self.mpstate.status.armed:
            # do not upload data over telemetry link if we are armed
            # perhaps we should just limit rate instead.
            return
        now = time.time()
        if self.auto:
            if now-self.last_auto > 2:
                self.last_auto = now
                print("Doing auto things")
                if self.idle_upload_mga_dbd():
                    self.auto_status = "DBD uploaded"

                if not self.idle_upload_mga_online():
                    self.auto_status = "Online uploaded"

                if not self.idle_upload_mga_offline():
                    self.auto_status = "Offline uploaded"
898416
def _target_load(self, load):
        '''
        
        '''
        mp_call = _metaproxy_call(self.opts, 'target_load')
        return mp_call(self, load)
129089
def nanoFTPProxy(host, port, user, passwd, type):
    
    libxml2mod.xmlNanoFTPProxy(host, port, user, passwd, type)
294571
def mavparms(logfile):
    ''''''
    mlog = mavutil.mavlink_connection(filename)

    while True:
        try:
            m = mlog.recv_match(type=['PARAM_VALUE', 'PARM'])
            if m is None:
                return
        except Exception:
            return
        if m.get_type() == 'PARAM_VALUE':
            pname = str(m.param_id).strip()
            value = m.param_value
        else:
            pname = m.Name
            value = m.Value
        if len(pname) > 0:
            if args.changesOnly is True and pname in parms and parms[pname] != value:
                print("%s %-15s %.6f -> %.6f" % (time.asctime(time.localtime(m._timestamp)), pname, parms[pname], value))

            parms[pname] = value
312533
public static void stopProxy(VersionedProtocol proxy) {
		if (proxy != null) {
			((Invoker) Proxy.getInvocationHandler(proxy)).close();
		}
	}
1104564
def call(self):
        ''''''
        from MAVProxy.modules.lib.wx_loader import wx

        # remap flags to wx descriptors
        flag_map = {
            'open': wx.FD_OPEN,
            'save': wx.FD_SAVE,
            'overwrite_prompt': wx.FD_OVERWRITE_PROMPT,
        }
        flagsMapped = map(lambda x: flag_map[x], self.flags)

        #need to OR together the elements of the flagsMapped tuple
        if len(flagsMapped) == 1:
            dlg = wx.FileDialog(None, self.title, '', "", self.wildcard, flagsMapped[0])
        else:
            dlg = wx.FileDialog(None, self.title, '', "", self.wildcard, flagsMapped[0]|flagsMapped[1])
        if dlg.ShowModal() != wx.ID_OK:
            return None
        return "\"" + dlg.GetPath().encode('utf8') + "\""
284670
protected final void invokeDraw(View view, Canvas canvas) {
        final ViewProxy proxy = (ViewProxy) view;
        proxy.invokeDraw(canvas);
    }
1037398
private void startProxy() throws Exception {
    mProxyProcess = ProxyProcess.Factory.create();
    Runnable runProxy = () -> {
      try {
        mProxyProcess.start();
      } catch (InterruptedException e) {
        // this is expected
      } catch (Exception e) {
        // Log the exception as the RuntimeException will be caught and handled silently by JUnit
        LOG.error("Start proxy error", e);
        throw new RuntimeException(e + " \n Start Proxy Error \n" + e.getMessage(), e);
      }
    };

    mProxyThread = new Thread(runProxy);
    mProxyThread.setName("ProxyThread-" + System.identityHashCode(mProxyThread));
    mProxyThread.start();
    TestUtils.waitForReady(mProxyProcess);
  }
245554
def call(self, func, *args, **kwargs):
        
        t0 = time.time()
        try:
            recv = self.call_async(func, *args, **kwargs)
            return self._rethrow(recv)
        finally:
            LOG.debug('Call took %d ms: %r', 1000 * (time.time() - t0),
                      mitogen.parent.CallSpec(func, args, kwargs))
856201
def mavlink_packet(self, m):
        ''''''
        if m.get_type() == 'SYSTEM_TIME':
            if self.system_time_settings.verbose:
                print("ST: Received from (%u/%u): %s" %
                      (m.get_srcSystem(), m.get_srcComponent(), m))
        if m.get_type() == 'TIMESYNC':
            if m.tc1 == 0:
                # this is a request for a timesync response
                time_ns = time.time() * 1000000000
                time_ns += 1234
                if True or self.system_time_settings.verbose:
                    if self.system_time_settings.verbose:
                        print("ST: received timesync; sending response: %u" %
                              (time_ns))
                    self.master.mav.timesync_send(time_ns,
                                                  m.ts1)
            else:
                if m.ts1 == self.last_sent_ts1:
                    # we sent this one!
                    now_ns = time.time() * 1000000000
                    now_ns += 1234
                    if self.system_time_settings.verbose:
                        print("ST: timesync response: sysid=%u latency=%fms" %
                              (m.get_srcSystem(),
                               (now_ns-self.last_sent_ts1)/1000000.0))
778520
def _work(self):
        """"""
        server = wsgi.Server(
            name=self._AGENT_BINARY,
            num_threads=CONF.AGENT.worker_count)
        server.start(
            application=_MetadataProxyHandler(),
            port=CONF.bind_port,
            host=CONF.bind_host)
        server.wait()
133800
def recvProxyData(self, data):
        """"""
        if self.initialized:
            self.sendData(data)
        else:
            self.queued_data.append(data)
37313
def process(filename):
    ''''''
    print("Processing %s" % filename)
    mlog = mavutil.mavlink_connection(filename, notimestamps=args.notimestamps,
                                      robust_parsing=args.robust)


    ext = os.path.splitext(filename)[1]
    isbin = ext in ['.bin', '.BIN']
    islog = ext in ['.log', '.LOG']
    output = None
    count = 1
    dirname = os.path.dirname(filename)

    if isbin or islog:
        extension = "bin"
    else:
        extension = "tlog"

    file_header = ''

    messages = []

    # we allow a list of modes that map to one mode number. This allows for --mode=AUTO,RTL and consider the RTL as part of AUTO
    modes = args.mode.upper().split(',')
    flightmode = None

    while True:
        m = mlog.recv_match()
        if m is None:
            break
        if args.link is not None and m._link != args.link:
            continue

        mtype = m.get_type()
        if mtype in messages:
            if older_message(m, messages[mtype]):
                continue

        # we don't use mlog.flightmode as that can be wrong if we are extracting a single link
        if mtype == 'HEARTBEAT' and m.get_srcComponent() != mavutil.mavlink.MAV_COMP_ID_GIMBAL and m.type != mavutil.mavlink.MAV_TYPE_GCS:
            flightmode = mavutil.mode_string_v10(m).upper()
        if mtype == 'MODE':
            flightmode = mlog.flightmode

        if (isbin or islog) and m.get_type() in ["FMT", "PARM", "CMD"]:
            file_header += m.get_msgbuf()
        if (isbin or islog) and m.get_type() == 'MSG' and m.Message.startswith("Ardu"):
            file_header += m.get_msgbuf()
        if m.get_type() in ['PARAM_VALUE','MISSION_ITEM']:
            timestamp = getattr(m, '_timestamp', None)
            file_header += struct.pack('>Q', timestamp*1.0e6) + m.get_msgbuf()

        if not mavutil.evaluate_condition(args.condition, mlog.messages):
            continue

        if flightmode in modes:
            if output is None:
                path = os.path.join(dirname, "%s%u.%s" % (modes[0], count, extension))
                count += 1
                print("Creating %s" % path)
                output = open(path, mode='wb')
                output.write(file_header)
        else:
            if output is not None:
                output.close()
                output = None

        if output and m.get_type() != 'BAD_DATA':
            timestamp = getattr(m, '_timestamp', None)
            if not isbin:
                output.write(struct.pack('>Q', timestamp*1.0e6))
            output.write(m.get_msgbuf())
1168759
async function mkProxyOrMockFile({dirPath, exclude, targetDir, proxyFolderName,
    mockFolderName, time, interval, isProxy, libPath}) {
//@formatter:on
    
    const relativePath = dirPath.replace(targetDir, '') || '/';
    const childList = await loadChildList(dirPath, exclude);

    const taskList = childList.map(child => {
        return ((async function handleFile() {
            const stat = await Fs.stat(Path.join(dirPath, child));
            if (stat.isFile()) {
                const fileRelativePath = relativePath + child;
                const isWs = _.endsWith(child, '-ws.js');

                const factory = {
                    'proxy_api'() {
                        return Render(PROXY_TPL,
                            {note: Common.NOTE, proxyFolderName, fileRelativePath});
                    },
                    'mock_api'() {
                        return Render(MOCK_API_TPL,
                            {note: Common.NOTE, mockFolderName, fileRelativePath, time});
                    },
                    'proxy_ws'() {
                        return Render(PROXY_TPL,
                            {note: Common.NOTE, proxyFolderName, fileRelativePath});
                    },
                    'mock_ws'() {
                        return Render(MOCK_WS_TPL, {
                            note: Common.NOTE,
                            mockFolderName,
                            fileRelativePath,
                            interval
                        });
                    }
                }[`${isProxy ? 'proxy' : 'mock'}_${isWs ? 'ws' : 'api'}`]();

                await Fs.writeFile(Path.join(libPath, child), factory);
                return;
            }

            if (stat.isDirectory()) {
                await mkProxyOrMockFile({
                    dirPath: Path.join(dirPath, child), exclude, targetDir, proxyFolderName,
                    mockFolderName, time, interval, isProxy, libPath
                });
            }
        })());
    });

    await Promise.all(taskList);
}
675358
def do_request(self, request, proxies, timeout, **_):
        """"""
        print('{0} {1}'.format(request.method, request.url))
        response = self.http.send(request, proxies=proxies, timeout=timeout,
                                  allow_redirects=False)
        response.raw = None  # Make pickleable
        return response
762302
function findProxyObject(uri, proxyName, callback) {
    var proxyObject = {},
        folderUri = path.join(uri, proxyName)

    iterateFiles(folderUri, function (fileName) {
        var relativePropertyName = path.relative(folderUri, fileName),
            relativeValue = path.relative(uri, fileName)

        relativePropertyName = relativePropertyName.replace(isFile, "")
        var props = relativePropertyName.split("/")

        props.reduce(function (memo, value, index) {
            if (index === props.length - 1) {
                memo[value] = relativeValue
            } else {
                return (memo[value] = memo[value] || {})
            }
        }, proxyObject)

    }, function (err) {
        callback(err, proxyObject)
    })

    //fs.readdir(folderUri, mapIntoProxyObject)

    function mapIntoProxyObject(err, files) {
        if (err) {
            return callback(err)
        }
        files.filter(isFileFunction).forEach(addToProxyObject)
        callback(null, proxyObject)
    }

    function addToProxyObject(fileName) {
        var propertyName = fileName.replace(isFile, "")

        proxyObject[propertyName] = 
            path.join(proxyName, fileName)
    }
}
1366871
def fast_sync_fetch(working_dir, import_url):
    
    try:
        fd, tmppath = tempfile.mkstemp(prefix='.blockstack-fast-sync-', dir=working_dir)
    except Exception, e:
        log.exception(e)
        return None
    
    log.debug("Fetch {} to {}...".format(import_url, tmppath))

    try:
        path, headers = urllib.urlretrieve(import_url, tmppath)
    except Exception, e:
        os.close(fd)
        log.exception(e)
        return None
    
    os.close(fd)
    return tmppath