UOWScope interface
174161
@Override
    public String getTaskId() {
        if (tc.isDebugEnabled())
            Tr.debug(tc, "getTaskId", _taskId);
        return _taskId;
    }
1262560
def _captureScreen(self, device_name):
        

        ## Define constants/structs
        class HBITMAP(ctypes.Structure):
            _fields_ = [("bmType", ctypes.c_long),
                        ("bmWidth", ctypes.c_long),
                        ("bmHeight", ctypes.c_long),
                        ("bmWidthBytes", ctypes.c_long),
                        ("bmPlanes", ctypes.wintypes.WORD),
                        ("bmBitsPixel", ctypes.wintypes.WORD),
                        ("bmBits", ctypes.wintypes.LPVOID)]
        class BITMAPINFOHEADER(ctypes.Structure):
            _fields_ = [("biSize", ctypes.wintypes.DWORD),
                        ("biWidth", ctypes.c_long),
                        ("biHeight", ctypes.c_long),
                        ("biPlanes", ctypes.wintypes.WORD),
                        ("biBitCount", ctypes.wintypes.WORD),
                        ("biCompression", ctypes.wintypes.DWORD),
                        ("biSizeImage", ctypes.wintypes.DWORD),
                        ("biXPelsPerMeter", ctypes.c_long),
                        ("biYPelsPerMeter", ctypes.c_long),
                        ("biClrUsed", ctypes.wintypes.DWORD),
                        ("biClrImportant", ctypes.wintypes.DWORD)]
        class BITMAPINFO(ctypes.Structure):
            _fields_ = [("bmiHeader", BITMAPINFOHEADER),
                        ("bmiColors", ctypes.wintypes.DWORD*3)]
        HORZRES = ctypes.c_int(8)
        VERTRES = ctypes.c_int(10)
        SRCCOPY =    0x00CC0020
        CAPTUREBLT = 0x40000000
        DIB_RGB_COLORS = 0

        ## Begin logic
        self._gdi32.CreateDCW.restype = ctypes.c_void_p
        hdc = self._gdi32.CreateDCW(ctypes.c_wchar_p(str(device_name)), 0, 0, 0) # Convert to bytestring for c_wchar_p type
        if hdc == 0:
            raise ValueError("Empty hdc provided")

        # Get monitor specs
        self._gdi32.GetDeviceCaps.argtypes = [ctypes.c_void_p, ctypes.c_int]
        screen_width = self._gdi32.GetDeviceCaps(hdc, HORZRES)
        screen_height = self._gdi32.GetDeviceCaps(hdc, VERTRES)

        # Create memory device context for monitor
        self._gdi32.CreateCompatibleDC.restype = ctypes.c_void_p
        self._gdi32.CreateCompatibleDC.argtypes = [ctypes.c_void_p]
        hCaptureDC = self._gdi32.CreateCompatibleDC(hdc)
        if hCaptureDC == 0:
            raise WindowsError("gdi:CreateCompatibleDC failed")

        # Create bitmap compatible with monitor
        self._gdi32.CreateCompatibleBitmap.restype = ctypes.c_void_p
        self._gdi32.CreateCompatibleBitmap.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int]
        hCaptureBmp = self._gdi32.CreateCompatibleBitmap(hdc, screen_width, screen_height)
        if hCaptureBmp == 0:
            raise WindowsError("gdi:CreateCompatibleBitmap failed")

        # Select hCaptureBmp into hCaptureDC device context
        self._gdi32.SelectObject.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
        self._gdi32.SelectObject(hCaptureDC, hCaptureBmp)

        # Perform bit-block transfer from screen to device context (and thereby hCaptureBmp)
        self._gdi32.BitBlt.argtypes = [
            ctypes.c_void_p,
            ctypes.c_int,
            ctypes.c_int,
            ctypes.c_int,
            ctypes.c_int,
            ctypes.c_void_p,
            ctypes.c_int,
            ctypes.c_int,
            ctypes.c_ulong
        ]
        self._gdi32.BitBlt(hCaptureDC, 0, 0, screen_width, screen_height, hdc, 0, 0, SRCCOPY | CAPTUREBLT)

        # Capture image bits from bitmap
        img_info = BITMAPINFO()
        img_info.bmiHeader.biSize = ctypes.sizeof(BITMAPINFOHEADER)
        img_info.bmiHeader.biWidth = screen_width
        img_info.bmiHeader.biHeight = screen_height
        img_info.bmiHeader.biPlanes = 1
        img_info.bmiHeader.biBitCount = 32
        img_info.bmiHeader.biCompression = 0
        img_info.bmiHeader.biClrUsed = 0
        img_info.bmiHeader.biClrImportant = 0

        buffer_length = screen_width * 4 * screen_height
        image_data = ctypes.create_string_buffer(buffer_length)

        self._gdi32.GetDIBits.restype = ctypes.c_int
        self._gdi32.GetDIBits.argtypes = [
            ctypes.c_void_p,
            ctypes.c_void_p,
            ctypes.c_uint,
            ctypes.c_uint,
            ctypes.c_void_p,
            ctypes.c_void_p,
            ctypes.c_uint
        ]
        scanlines = self._gdi32.GetDIBits(
            hCaptureDC,
            hCaptureBmp,
            0,
            screen_height,
            ctypes.byref(image_data),
            ctypes.byref(img_info),
            DIB_RGB_COLORS)
        if scanlines != screen_height:
            raise WindowsError("gdi:GetDIBits failed")
        final_image = ImageOps.flip(
            Image.frombuffer(
                "RGBX",
                (screen_width, screen_height),
                image_data,
                "raw",
                "RGBX",
                0,
                1))
        # Destroy created device context & GDI bitmap
        self._gdi32.DeleteObject.argtypes = [ctypes.c_void_p]
        self._gdi32.DeleteObject(hdc)
        self._gdi32.DeleteObject(hCaptureDC)
        self._gdi32.DeleteObject(hCaptureBmp)
        return final_image
1290765
def _setup_pyudev_monitoring(self):
        
        context = pyudev.Context()
        monitor = pyudev.Monitor.from_netlink(context)
        self.udev_observer = pyudev.MonitorObserver(monitor, self._udev_event)
        self.udev_observer.start()
        self.py3_wrapper.log("udev monitoring enabled")
1284099
def focusWindow(self, hwnd):
        
        Debug.log(3, "Focusing window: " + str(hwnd))
        SW_RESTORE = 9
        if ctypes.windll.user32.IsIconic(hwnd):
            ctypes.windll.user32.ShowWindow(hwnd, SW_RESTORE)
        ctypes.windll.user32.SetForegroundWindow(hwnd)
1344121
private void showSettingsMenu(final Cursor cursor) {
        Log.d(TAG, "showSettingsMenu");
        enableSettingsCursor(cursor);
        context.runOnGlThread(new Runnable() {
            @Override
            public void run() {
                new SettingsView(context, scene, CursorManager.this,
                        settingsCursor.getIoDevice().getCursorControllerId(), cursor, new
                        SettingsChangeListener() {
                            @Override
                            public void onBack(boolean cascading) {
                                disableSettingsCursor();
                            }

                            @Override
                            public int onDeviceChanged(IoDevice device) {
                                // we are changing the io device on the settings cursor
                                removeCursorFromScene(settingsCursor);
                                IoDevice clickedDevice = getAvailableIoDevice(device);
                                settingsCursor.setIoDevice(clickedDevice);
                                addCursorToScene(settingsCursor);
                                return device.getCursorControllerId();
                            }
                        });
            }
        });
    }
988497
public void registerCallback(UOWScopeCallback callback)
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "registerCallback", new Object[]{callback, this});
        
        _callbackManager.addCallback(callback);
        
        if (tc.isEntryEnabled()) Tr.exit(tc, "registerCallback");
    }
143306
public void addScope(ApiAppOauthScopeType scope) {
        if (oauth == null) {
            oauth = new ApiAppOauth();
        }
        oauth.addScope(scope);
    }
709985
def mwl(self, event):
        
        if event.num == 4: # up on Linux
            self.top.f.canvas.yview_scroll(-1*self._tmwm, 'units')
        elif event.num == 5: # down on Linux
            self.top.f.canvas.yview_scroll(1*self._tmwm, 'units')
        else: # assume event.delta has the direction, but reversed sign
            self.top.f.canvas.yview_scroll(-(event.delta)*self._tmwm, 'units')
49712
def attach(self, gui):
        """"""
        super(CorrelogramView, self).attach(gui)
        self.actions.add(self.toggle_normalization, shortcut='n')
        self.actions.separator()
        self.actions.add(self.set_bin, alias='cb')
        self.actions.add(self.set_window, alias='cw')
618181
function(value) {
		var any = false;

		if (value.uzoom != undefined) {
			this.elUZoom.value = value.uzoom;
			any = true;
		} else if (value.nzoom != undefined) {
			this.elUZoom.value = this.apid.f_zoom.to_universal(value.uzoom);
			any = true;
		}

		if (value.lat != undefined) {
			this.elLat.value = value.lat;
			any = true;
		}

		if (value.lon != undefined) {
			this.elLon.value = value.lon;
			any = true;
		}

		if (any) {
			this.apid.onposition();
		}
	}
741015
def StartGuiSession(self):
		
		from UcsBase import WriteUcsWarning, UcsUtils, UcsValidationException
		import urllib, tempfile, fileinput, os, subprocess, platform

		osSupport = ["Windows", "Linux", "Microsoft"]

		if platform.system() not in osSupport:
			raise UcsValidationException("Currently works with Windows OS and Ubuntu")
		# raise Exception("Currently works with Windows OS and Ubuntu")

		try:
			javawsPath = UcsUtils.GetJavaInstallationPath()
			# print r"%s" %(javawsPath)
			if javawsPath != None:

				url = "%s/ucsm/ucsm.jnlp" % (self.Uri())
				source = urllib.urlopen(url).read()

				jnlpdir = tempfile.gettempdir()
				jnlpfile = os.path.join(jnlpdir, "temp.jnlp")

				if os.path.exists(jnlpfile):
					os.remove(jnlpfile)

				jnlpFH = open(jnlpfile, "w+")
				jnlpFH.write(source)
				jnlpFH.close()

				for line in fileinput.input(jnlpfile, inplace=1):
					if re.search(r'^\s*</resources>\s*$', line):
						print '\t<property name="log.show.encrypted" value="true"/>'
					print line,

				subprocess.call([javawsPath, jnlpfile])

				if os.path.exists(jnlpfile):
					os.remove(jnlpfile)
			else:
				return None

		except Exception, err:
			fileinput.close()
			if os.path.exists(jnlpfile):
				os.remove(jnlpfile)
			raise
466291
public boolean inGlobalHoistScope() {
    Node cfgRoot = getCfgRoot();
    checkState(
        cfgRoot.isScript()
            || cfgRoot.isRoot()
            || cfgRoot.isBlock()
            || cfgRoot.isFunction()
            || cfgRoot.isModuleBody(),
        cfgRoot);
    return cfgRoot.isScript() || cfgRoot.isRoot() || cfgRoot.isBlock();
  }
805564
def _umask(self):
        """"""
        if self.filesystem.is_windows_fs:
            # windows always returns 0 - it has no real notion of umask
            return 0
        if sys.platform == 'win32':
            # if we are testing Unix under Windows we assume a default mask
            return 0o002
        else:
            # under Unix, we return the real umask;
            # as there is no pure getter for umask, so we have to first
            # set a mode to get the previous one and then re-set that
            mask = os.umask(0)
            os.umask(mask)
            return mask
1106776
def showxy(self, viewer, data_x, data_y):
        
        # This is an optimization to get around slow coordinate
        # transformation by astropy and possibly other WCS packages,
        # which causes delay for other mouse tracking events, e.g.
        # the zoom plugin.
        # We only update the under cursor information every period
        # defined by (self.cursor_interval) sec.
        #
        # If the refresh interval has expired then update the info;
        # otherwise (re)set the timer until the end of the interval.
        cur_time = time.time()
        elapsed = cur_time - self._cursor_last_update
        if elapsed > self.cursor_interval:
            # cancel timer
            self._cursor_task.clear()
            self.gui_do_oneshot('field-info', self._showxy,
                                viewer, data_x, data_y)
        else:
            # store needed data into the timer data area
            self._cursor_task.data.setvals(viewer=viewer,
                                           data_x=data_x, data_y=data_y)
            # calculate delta until end of refresh interval
            period = self.cursor_interval - elapsed
            # set timer conditionally (only if it hasn't yet been set)
            self._cursor_task.cond_set(period)
        return True
847793
function UniversalCamera(name, position, scene) {
            var _this = _super.call(this, name, position, scene) || this;
            _this.inputs.addGamepad();
            return _this;
        }
1117333
function UBeaconUARTController( serialPort , baudRate , discoverDevice )
{
  var self = this;
  this.ready = false;
  this.devices = {};

  this._callbacks = [];
  this._timeoutMs = 5000;
  this.cmdGetPrefixByte =         0x67;
  this.cmdSetPrefixByte =         0x73;
  this.cmdResponsePrefixByte =    0x72; 
  this.delimiterByte =            0x3A;

  /**
   * Events emitted by this library
   */
  this.EVENTS = {
    UART_READY:                   'uart_ready',
    ERROR:                        'error',
    UBEACON_READY:                'board_ready',
    CONNECTED:                    'connected',
    ALARM:                        'alarm',
    BUTTON:                       'button',
    BATTERY_THRESHOLD:            'battery_threshold',
    MESH_MSG__ACK:                'mesh-ack',
    MESH_MSG__USER:               'mesh-user',
    MESH_MSG__REMOTE_MANAGEMENT:  'mesh-remote-management',
    MSG:                          'message',
    DFU_ERROR:                    'dfu_error',
    DFU_WRITTEN:                  'dfu_written',
  };


  //Available commands
  this.uartCmd = {

    //{cmd: coommandByte, availability: versionOfUartProtocol}
    //If versionOfUartProtocol is null then it is available for all versions and devices
    none:                   {cmd:0xFF,availability:'0.0.0'},   //
    protocolVersion:        {cmd:0x30,availability:null},   //'0'
    firmwareVersion:        {cmd:0x31,availability:null},   //'1'
    hardwareModel:          {cmd:0x32,availability:null},   //'2'
    hardwareVersion:        {cmd:0x33,availability:null},   //'3'
    bdaddr:                 {cmd:0x34,availability:null},   //'4'
    firmwareBuild:          {cmd:0x36,availability:'0.2.0'},   //'6'
    serialNumber:           {cmd:0x37,availability:null},   //'7'
    connectable:            {cmd:0x75,availability:'0.1.0'},   //'u'
    connectionInfo:         {cmd:0x79,availability:'0.1.1'},   //'y'
    ledSettingsRegister:    {cmd:0x6c,availability:'0.1.0'},   //'l'
    uartSettingsRegister:   {cmd:0x6f,availability:'0.1.0'},   //'o'
    txPower:                {cmd:0x35,availability:'0.1.0'},   //'5'
    batteryLevel:           {cmd:0x38,availability:'0.1.0'},   //'8'
    temperature:            {cmd:0x64,availability:'0.2.0'},   //'d' 
    RTCAlarmEnabled:        {cmd:0x6b,availability:'0.1.0'},   //'k'
    RTCSettingsRegister:    {cmd:0x6a,availability:'0.1.0'},   //'j'
    RTCTime:                {cmd:0x77,availability:'0.1.0'},   //'w'
    RTCSchedule:            {cmd:0x72,availability:'0.1.0'},   //'r'
    advertising:            {cmd:0x74,availability:'0.1.0'},   //'t'
    advertisingInterval:    {cmd:0x69,availability:'0.1.0'},   //'i'
    advertisingSettings:    {cmd:0x70,availability:'0.2.1'},   //'p'
    uuid:                   {cmd:0x61,availability:'0.1.0'},   //'a'
    major:                  {cmd:0x66,availability:'0.1.0'},   //'f'
    minor:                  {cmd:0x67,availability:'0.1.0'},   //'g'
    eddystoneURL:           {cmd:0x65,availability:'0.2.1'},   //'e'
    measuredStrength:       {cmd:0x76,availability:'0.1.0'},   //'v'
    serviceId:              {cmd:0x62,availability:'0.1.0'},   //'b'
    led:                    {cmd:0x68,availability:'0.1.2'},   //'h'
    command:                {cmd:0x63,availability:'0.1.0'},   //'l'
    meshSettingsRegister:   {cmd:0x6d,availability:'0.1.0'},   //'m'
    meshNetworkUUID:        {cmd:0x78,availability:'0.1.0'},   //'x'
    meshDeviceId:           {cmd:0x7a,availability:'0.1.0'},   //'z'
    meshStats:              {cmd:0x73,availability:'0.1.0'},   //'s'

    eventReady:             {cmd:0x21,availability:'0.1.0'},   //'!'
    eventConnected:         {cmd:0x40,availability:'0.1.1'},   //'@'
    eventButton:            {cmd:0x24,availability:'0.1.0'},   //'$'
    eventMeshMessage:       {cmd:0x5e,availability:'0.1.0'},   //'^'
    eventDfuError:          {cmd:0x2a,availability:'0.2.0'},   //'*'
    eventDfuWritten:        {cmd:0x23,availability:'0.2.0'},   //'#'
  };

  //Basic data of the connected device
  this.deviceData = {
    hardwareModel: null,
    hardwareVersion: null,
    firmwareVersion: null,
    uartProtocolVersion: null
  };


  if( serialPort != null ){
    this.serialPort = new SerialPort( serialPort, { 
      baudrate: baudRate, 
      parser: serialport.parsers.readline('\r\n')
    });

    this.serialPort.on('open', function(){
        
      self.serialPort.flush(function(err){
      });

      self.serialPort.on('data', function(data) {
        //filter incoming UART responses data 
        var tmp = /(r:.*$)/.exec(data);
        if( uartRawInputLoggingEnabled === true ){
          console.log( '[UART,' + (+new Date()) + ',!!]', data );
        }

        if( tmp != null && tmp.length >= 1 ){
          self.emit( 'data' , tmp[1] );
          self.parseIncomingSerialData( tmp[1] );
        }
      });
      
      if( discoverDevice === false ){
        //If no automatic discovery will be done we have to assume some UART protocol version
        self.deviceData.uartProtocolVersion = '0.1.0';
        self.ready = true;
        self.emit( self.EVENTS.UART_READY );        
      }else{
        //discover basic device info 
        self.discoverBasicDeviceData( function(data, error){
          if( error === null ){
            self.ready = true;
            self.emit( self.EVENTS.UART_READY );
          }else{
            self.emit( self.EVENTS.ERROR, error );
          }
        });
      }

      
    });
  }
}
1372149
def display(self):
        """"""
        if self.data is None:
            return

        if self.scene is not None:
            self.y_scrollbar_value = self.verticalScrollBar().value()
            self.scene.clear()

        self.create_chan_labels()
        self.create_time_labels()

        window_start = self.parent.value('window_start')
        window_length = self.parent.value('window_length')

        time_height = max([x.boundingRect().height() for x in self.idx_time])
        label_width = window_length * self.parent.value('label_ratio')
        scene_height = (len(self.idx_label) * self.parent.value('y_distance') +
                        time_height)

        self.scene = QGraphicsScene(window_start - label_width,
                                    0,
                                    window_length + label_width,
                                    scene_height)
        self.setScene(self.scene)

        self.idx_markers = []
        self.idx_annot = []
        self.idx_annot_labels = []

        self.add_chan_labels()
        self.add_time_labels()
        self.add_traces()
        self.display_grid()
        self.display_markers()
        self.display_annotations()

        self.resizeEvent(None)
        self.verticalScrollBar().setValue(self.y_scrollbar_value)
        self.parent.info.display_view()
        self.parent.overview.display_current()