Exemple #1
0
class NautilusPropertyPage:
    """Property page main widget class."""
    def __init__(self, git_uri):
        self._git = Git(git_uri)
        self._watchdog = WatchDog(self._git.dir)
        self._watchdog.connect("refresh", self._refresh)

        self._builder = Gtk.Builder()
        self._builder.add_from_resource('/com/nautilus/git/ui/page.ui')
        self._build_widgets()

    @property
    def main(self):
        return self._builder.get_object("main")

    def _build_widgets(self):
        """Build needed widgets."""
        self._builder.get_object("branch").set_text(self._git.get_branch())
        status = self._git.get_status()

        status_widgets = ["added", "removed", "modified"]
        for widget_name in status_widgets:
            count = str(len(status[widget_name]))
            widget = self._builder.get_object(widget_name)
            widget.set_text(_("{0} file.").format(count))

    def _refresh(self, event):
        branch = self._builder.get_object("branch")
        branch.set_text(self._git.get_branch())
        branch.show()
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-v", "--verbose", action="store_true", default=False)

    args = parser.parse_args()

    log_format = "%(asctime)s %(levelname)-8s %(processName)-10s %(name)-10s %(message)s"
    if args.verbose:
        logging.basicConfig(format=log_format, level=logging.DEBUG)
    else:
        logging.basicConfig(format=log_format, level=logging.INFO)

    log = logging.getLogger()

    loop = asyncio.get_event_loop()

    server = WatchDog()

    try:
        log.info("Start all service")
        server.start()
        loop.run_forever()
    except KeyboardInterrupt:
        log.info("Receive close signal")
    except:
        log.info(sys.exc_info())

    loop.run_until_complete(asyncio.wait([shutdown(server)]))

    loop.close()

    if loop.is_closed():
        loop.stop()
Exemple #3
0
    def __init__(self, git_uri):
        self._git = Git(git_uri)
        self._watchdog = WatchDog(self._git.dir)
        self._watchdog.connect("refresh", self._refresh)

        self._builder = Gtk.Builder()
        self._builder.add_from_resource('/com/nautilus/git/ui/page.ui')
        self._build_widgets()
def main():

    real_im = io.imread("test_pictures/36.jpg")

    # Camera pos, FOV, aspect ratio, nozzle width, RGB color
    watchdog = WatchDog([273.7, -5, 15.0], [1.123, 0.05, 0.85], np.pi / 3.0,
                        1.0, 0.4, [0.0, 0.0, 1.0])
    watchdog.add_light([163.7, 110, 47.65], [1.0, 1.0, 1.0], 5000.0, 1000.0)
    watchdog.read_layers_from_file(
        "test_pictures/test_timelapse_eartube.gcode")
    mesh = watchdog.build_object_mesh(watchdog.layers, [], 36)
    rendered_im = watchdog.render_mesh(mesh, real_im.shape[1],
                                       real_im.shape[0])
    watchdog.test_compare_images(real_im, rendered_im)
Exemple #5
0
    def __init__(self, git_uri, window):
        self._window = window
        self._git = Git(git_uri)
        self._watchdog = WatchDog(self._git.dir)
        self._watchdog.connect("refresh", self._refresh)

        self._builder = Gtk.Builder()

        self._builder.add_from_resource('/com/nautilus/git/ui/location.ui')
        self._builder.connect_signals({
            "open_remote_clicked": self._open_remote_browser,
            "compare_commits_clicked": self._compare_commits,
            "popover_clicked": self._trigger_popover,
            "branch_clicked": self._update_branch
        })
        self._build_widgets()
Exemple #6
0
 def run(self):
     while True:
         path = pathPool.get()
         if path:
             win = WatchDog(path, self.timing, self.q, self.upload)
             t = multiprocessing.Process(target=logGen, args=(win, ))
             t.start()
             self.threads.append(t)
Exemple #7
0
class NautilusLocation:
    """Location bar main widget."""
    def __init__(self, git_uri, window):
        self._window = window
        self._git = Git(git_uri)
        self._watchdog = WatchDog(self._git.dir)
        self._watchdog.connect("refresh", self._refresh)

        self._builder = Gtk.Builder()

        self._builder.add_from_resource('/com/nautilus/git/ui/location.ui')
        self._builder.connect_signals({
            "open_remote_clicked": self._open_remote_browser,
            "compare_commits_clicked": self._compare_commits,
            "popover_clicked": self._trigger_popover,
            "branch_clicked": self._update_branch
        })
        self._build_widgets()

    def _build_widgets(self):
        """Build needed widgets."""
        self._popover = self._builder.get_object("popover")
        project_branch = self._git.get_project_branch()
        self._builder.get_object("branch").set_label(project_branch)
        remote_url = self._git.get_remote_url()
        # Show the open remote button only if it's a url
        has_remote = False
        if remote_url.lower().startswith(("http://", "https://", "wwww")):
            self._builder.get_object("open_remote").show()
            has_remote = True

        files = self._git.get_modified()
        # Show the compare commits button only if there's any modification
        has_files = False
        if files:
            self._builder.get_object("compare_commits").show()
            has_files = True

        if not has_files and not has_remote:
            self._builder.get_object("more_button").set_sensitive(False)

        status = self._git.get_status()
        widgets = ["added", "modified", "removed"]
        for widget_name in widgets:
            files = status[widget_name]
            files.sort()
            widget = self._builder.get_object(widget_name)
            if files:
                widget.set_label(str(len(files)))
                box = self._builder.get_object(widget_name + "_content")
                for file_ in files:
                    file_label = Gtk.Label(file_)
                    file_label.set_halign(Gtk.Align.START)
                    file_label.show()
                    box.pack_start(file_label, False, False, 6)
            else:
                widget.hide()

    @property
    def main(self):
        return self._builder.get_object("main")

    def _update_branch(self, button):
        """Open the branch widget."""
        branch_ = BranchWidget(self._git, self._window)
        branch_.connect("refresh", self._refresh)

    def _refresh(self, event):
        action = self._window.lookup_action("reload")
        action.emit("activate", None)

    def _trigger_popover(self, popover):
        """Show/hide popover."""
        if popover.get_visible():
            popover.hide()
        else:
            popover.show()

    def _compare_commits(self, *args):
        """Compare commits widget creation."""
        widget = NautilusGitCompare(self._git)
        self._popover.hide()

    def _open_remote_browser(self, *args):
        """Open the remote url on the default browser."""
        Gio.app_info_launch_default_for_uri(self._git.get_remote_url())
        self._popover.hide()
Exemple #8
0
if __name__ == '__main__':
    # gt = guiThread()
    # gt.start()

    #Declare the run_time
    run_time_in_seconds = 4
    threads = []
    queue = queue.Queue()
    queue.maxsize = 20
    #Create 2 Producer and 3 Consumer
    p1 = Producer(queue)
    c1 = Consumer(queue)
    p2 = Producer(queue)
    c2 = Consumer(queue)
    c3 = Consumer(queue)
    #Add them to the list
    threads.append(p1)
    threads.append(c1)
    threads.append(p2)
    threads.append(c2)
    threads.append(c3)
    #Initialize watchdog object
    w = WatchDog(run_time_in_seconds, *threads)
    w.start()
    #Start and wait for threads to finish
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()
    w.join()
    # gt.join()
Exemple #9
0
 def run(self):
     while True:
         path = pathPool.get()
         if path:
             w = WatchDog(path, 2)
             w.monitor()
Exemple #10
0
app_options = get_app_options()

# 3. initialize global logger
loggerfactory = LoggerFactory(__name__)
if app_options['app_debug']:
    loggerfactory.add_handler(handler='CONSOLE', format=DEFAULT_LOG_FORMAT, 
    log_dir=LOG_PATH, log_name=LOG_FILE_NAME, level='INFO')
loggerfactory.add_handler(handler='TIME_FILE', format=DEFAULT_LOG_FORMAT, 
log_dir=LOG_PATH, log_name=LOG_FILE_NAME, level='INFO')
logger = loggerfactory.get_logger()

logger.info("Launch options: %s" % str(app_options))
# 4. initialize functional components and api resources
event_reporter = None
if app_options['app_event']:
    logger.info("Event reporter: select real event collector client")
    event_reporter = EventReporter(logger=logger)
else:
    logger.info("Event reporter: select fake reporter")
    event_reporter = FakeReporter(logger=logger)

# wait for completion of event reporter initialization
time.sleep(5)

watchdog = WatchDog(contacts=app_options['contacts'], reporter=event_reporter, logger=logger, alive=app_options['app_alive'])
watchdog.start()
api.add_resource(SensorReportAPI, '/report', '/report//', resource_class_kwargs={ 'event_reporter': event_reporter, 'watchdog': watchdog, 'logger': logger})

if __name__ == "__main__":
    # launch the app
    app.run(debug=True, port=5000)
Exemple #11
0
async def main():
    async for result in WatchDog(*WatchDogParser.parser(args.targets),
                                 pause=args.wait,
                                 timeout=args.timeout,
                                 ipv6=args.ipv6).run():
        print(result)
Exemple #12
0
                series[data_node['host']]['metadata'].append(data_node)

    summary = status[0] if status else {}
    return data({
        "nodes": nodes,
        "time_lines": time_lines,
        "series": [value for key, value in series.items()],
        "summary": summary
    })


@app.route('/login', methods=['POST'])
def login():
    form_data = request.get_json()
    # TODO: should validation from the database later
    if form_data['username'] == 'admin':
        return success('登录成功')
    return error('登录失败')


if __name__ == '__main__':
    # 开始运行整体程序
    logger.info('start the server ...')
    watch_dog = WatchDog(
        options=options,
        data_nodes=data_nodes,
    )
    watch_dog.start()
    logger.info('server has been started ...')
    app.run(port=5000, host='0.0.0.0')
Exemple #13
0
 def run(self):
     while True:
         path = pathPool.get()
         if path:
             w = WatchDog(path, self.timing, self.upload)
             w.monitor()
Exemple #14
0
from watchdog import WatchDog

wd = WatchDog()

if __name__ == "__main__":
    wd.run()
Exemple #15
0
 def run(self):
     while True:
         path = pathPool.get()
         if path:
             w = WatchDog(path, 2)
             w.monitor()
Exemple #16
0
 def run(self):
     while True:
         path = pathPool.get()
         if path:
             w = WatchDog(path, self.timing, self.upload)
             w.monitor()