Set up inotify manager.

            See https://github.com/seb-m/pyinotify/.
423549
def setup(self):
        
        if not pyinotify.WatchManager:
            raise error.UserError("You need to install 'pyinotify' to use %s (%s)!" % (
                self.__class__.__name__, pyinotify._import_error)) # pylint: disable=E1101, W0212

        self.manager = pyinotify.WatchManager()
        self.handler = TreeWatchHandler(job=self)
        self.notifier = pyinotify.AsyncNotifier(self.manager, self.handler)

        if self.LOG.isEnabledFor(logging.DEBUG):
            mask = pyinotify.ALL_EVENTS
        else:
            mask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_MOVED_TO # bogus pylint: disable=E1101

        # Add all configured base dirs
        for path in self.config.path:
            self.manager.add_watch(path.strip(), mask, rec=True, auto_add=True)
1248093
def create():
        
        # First, try to use ctypes.
        if ctypes:
            inotify = _CtypesLibcINotifyWrapper()
            if inotify.init():
                return inotify
        # Second, see if C extension is compiled.
        if inotify_syscalls:
            inotify = _INotifySyscallsWrapper()
            if inotify.init():
                return inotify
797209
def init_app(self, app):
        """"""
        app.extensions['invenio-documents'] = self
        app.cli.add_command(cmd)
174454
def notify(self):
        
        if self._notify is None:
            from twilio.rest.notify import Notify
            self._notify = Notify(self)
        return self._notify
872178
def notify(title, message, retcode=None):
    """"""
    if not path.exists(config_file):
        if not path.exists(config_dir):
            makedirs(config_dir)
        print("Follow the instructions to configure the Telegram backend.\n")
        configure(config_file)
    send(messages=[message], conf=config_file)
396591
def register():
    """"""
    if not plim:
        logger.warning('`slim` failed to load dependency `plim`. '
                       '`slim` plugin not loaded.')
        return
    if not mako:
        logger.warning('`slim` failed to load dependency `mako`. '
                       '`slim` plugin not loaded.')
        return
    if not bs:
        logger.warning('`slim` failed to load dependency `BeautifulSoup4`. '
                       '`slim` plugin not loaded.')
        return
    if not minify:
        logger.warning('`slim` failed to load dependency `htmlmin`. '
                       '`slim` plugin not loaded.')
        return

    signals.get_writer.connect(get_writer)
385968
function watchifyFile(src, out) {
    var opts = assign({}, watchify.args, {
        entries: src,
        standalone: "NavMesh",
        debug: true
    });
    var b = watchify(browserify(opts));
    function bundle() {
        return b.bundle()
            .on('error', gutil.log.bind(gutil, "Browserify Error"))
            .pipe(source(src.replace(/^src\//, '')))
            .pipe(derequire())
            .pipe(gulp.dest(out));
    }
    b.on('update', bundle);
    b.on('log', gutil.log);
    return bundle();
}
947018
@SuppressWarnings({"unused", "WeakerAccess"})
    public void initializeInbox(){
        if(getConfig().isAnalyticsOnly()){
            getConfigLogger().debug(getAccountId(),"Instance is analytics only, not initializing Notification Inbox");
            return;
        }
        postAsyncSafely("initializeInbox", new Runnable() {
            @Override
            public void run() {
                _initializeInbox();
            }
        });
    }
180581
def setup_signals(self, ):
        
        self.showfilter_tb.toggled.connect(self.switch_showfilter_icon)
        self.addnew_tb.clicked.connect(self.open_addnew_win)
        self.search_le.editingFinished.connect(self.update_filter)
        for cb in (self.loaded_checkb, self.unloaded_checkb, self.imported_checkb, self.empty_checkb,
                   self.newest_checkb, self.old_checkb, self.alien_checkb):
            cb.toggled.connect(self.update_filter)
758664
def notify(args):
    
    from jcvi.utils.iter import flatten

    valid_notif_methods.extend(available_push_api.keys())

    fromaddr = get_email_address(whoami="notifier")

    p = OptionParser(notify.__doc__)
    p.add_option("--method", default="email", choices=valid_notif_methods,
                 help="Specify the mode of notification [default: %default]")
    p.add_option("--subject", default="JCVI: job monitor",
                 help="Specify the subject of the notification message")
    p.set_email()

    g1 = OptionGroup(p, "Optional `push` parameters")
    g1.add_option("--api", default="pushover", \
                  choices=list(flatten(available_push_api.values())),
                  help="Specify API used to send the push notification")
    g1.add_option("--priority", default=0, type="int",
                  help="Message priority (-1 <= p <= 2) [default: %default]")
    g1.add_option("--timestamp", default=None, type="int", \
                  dest="timestamp", \
                  help="Message timestamp in unix format [default: %default]")
    p.add_option_group(g1)

    opts, args = p.parse_args(args)

    if len(args) == 0:
        logging.error("Please provide a brief message to be sent")
        sys.exit(not p.print_help())

    subject = opts.subject
    message = " ".join(args).strip()

    if opts.method == "email":
        toaddr = opts.email.split(",")   # TO address should be in a list
        for addr in toaddr:
            if not is_valid_email(addr):
                logging.debug("Email address `{0}` is not valid!".format(addr))
                sys.exit()
        send_email(fromaddr, toaddr, subject, message)
    else:
        pushnotify(subject, message, api=opts.api, priority=opts.priority, \
                   timestamp=opts.timestamp)
1041370
def on_attach_request(self, py_db, request):
        '''
        
        '''
        self.api.set_enable_thread_notifications(py_db, True)
        self._set_debug_options(py_db, request.arguments.kwargs)
        response = pydevd_base_schema.build_response(request)
        return NetCommand(CMD_RETURN, 0, response, is_json=True)
1289728
def detect(self, app):
        
        script = os.path.join(self.folder, 'bin', 'detect')
        cmd = '%s %s' % (script, app.folder)
        result = run(cmd)
        return result.status_code == 0
257786
def script(inbox, cfg):
    
    script_name = cfg["id"]
    script_id = str(abs(hash((cfg["id"],) + tuple(inbox[0].values()))))[0:8]
    # LOG.log(mp.DEFAULT, "@papy;script %s:%s started" % (script_name, script_id))
    # LOG.log(mp.SUBDEFAULT, "@papy;%s:%s received: %s" % (script_name, script_id, inbox))
    args = {}
    args["params"] = dict(cfg["params"])
    args["in"] = {}
    for in_port in cfg["in"]:
        for inin_ports in inbox:
            in_path = inin_ports.get(in_port, None)
            if (in_path is not None):
                # first matching input-output (including type) port is linked remaining ignored
                args["in"][in_port] = in_path
                break
    # check that all input ports are connected
    if len(args["in"]) < len(cfg["in"]):
        raise Exception("not all in_ports connected, got: %s" % (args["in"],))
    # create output file for out_ports
    args["out"] = {}
    out = {}
    for i, (out_port, out_ext) in enumerate(cfg["out"]):
        if cfg["in"] == tuple(out_port_ for out_port_, _ in cfg["out"]):
            pfx = args["in"][cfg["in"][i]].split("/")[-1].split(".")[0] + "_"
            base = cfg["id"]
        else:
            pfx = args["in"][cfg["in"][0]].split("/")[-1].split(".")[0] + "_"
            base = cfg["id"] + "-" + out_port 
        if out_ext:
            out_path = cfg["dir"] + "/" + pfx + base + "." + out_ext
        else:
            out_path = cfg["dir"] + "/" + pfx + base
        args["out"][out_port] = out_path
        out[out_port] = out_path
    # evaluate and check for errors
    ret = _eval_script(cfg["evaluator"], cfg["preamble"], cfg["dir"], cfg["executable"], cfg["script"], args)
    if ret[0] != 0:
        # LOG.error("@papy;%s:%s %s:%s:%s" % (script_name, script_id, ret[0], 
        #                                                              ret[1].replace("\n", "<br>"), 
        #                                                              ret[2].replace("\n", "<br>")))
        raise Exception(ret[0], cfg["script"], ret[1], ret[2])
    #LOG.log(mp.SUBDEFAULT, "@papy;%s:%s produced:%s" % (script_name, script_id, out))
    #LOG.log(mp.DEFAULT, "@papy;script %s:%s finished" % (script_name, script_id))
    return out
892354
def doc_watch():
    """"""
    try:
        from watchdog.events import FileSystemEventHandler
        from watchdog.observers import Observer
    except ImportError:
        print_failure_message('Install the watchdog package to use this task, '
                              "i.e., `pip install watchdog'.")
        raise SystemExit(1)

    class RebuildDocsEventHandler(FileSystemEventHandler):
        def __init__(self, base_paths):
            self.base_paths = base_paths

        def dispatch(self, event):
            """Dispatches events to the appropriate methods.
            :param event: The event object representing the file system event.
            :type event: :class:`watchdog.events.FileSystemEvent`
            """
            for base_path in self.base_paths:
                if event.src_path.endswith(base_path):
                    super(RebuildDocsEventHandler, self).dispatch(event)
                    # We found one that matches. We're done.
                    return

        def on_modified(self, event):
            print_failure_message('Modification detected. Rebuilding docs.')
            # # Strip off the path prefix.
            # import os
            # if event.src_path[len(os.getcwd()) + 1:].startswith(
            #         CODE_DIRECTORY):
            #     # sphinx-build doesn't always pick up changes on code files,
            #     # even though they are used to generate the documentation. As
            #     # a workaround, just clean before building.
            doc_html()
            print_success_message('Docs have been rebuilt.')

    print_success_message(
        'Watching for changes in project files, press Ctrl-C to cancel...')
    handler = RebuildDocsEventHandler(get_project_files())
    observer = Observer()
    observer.schedule(handler, path='.', recursive=True)
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
        observer.join()
394622
def notify(class_):
		
		# TODO: Implement Microsoft UIPI (User Interface Privilege Isolation) to
		#  elevate privilege to system level so the system gets this notification
		# for now, this must be run as admin to work as expected
		return_val = ctypes.wintypes.DWORD()
		res = message.SendMessageTimeout(
			message.HWND_BROADCAST,
			message.WM_SETTINGCHANGE,
			0,  # wparam must be null
			'Environment',
			message.SMTO_ABORTIFHUNG,
			5000,  # timeout in ms
			return_val,
		)
		error.handle_nonzero_success(res)
1218805
static void triggerUdevNotification(String sysClass) {
        File[] devices = new File("/sys/class/" + sysClass).listFiles();
        byte[] action = "change".getBytes();
        for (File device: devices) {
            File uevent = new File(device, "uevent");
            if (uevent.exists()) {
                try {
                    write(uevent.getAbsolutePath(), action);
                } catch (IOException e) {
                    System.err.println("Udev: Failed to write to " + uevent);
                    System.err.println("      Check that you have permission to access input devices");
                    if (!e.getMessage().contains("Permission denied")) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
765695
def install_monitor(self, mon):
        """"""
        assert self.binded
        for module in self._modules:
            module.install_monitor(mon)