Esempio n. 1
0
def cli(container, no_name, pretty, stdin):

    # TODO: -i, -t, -d as added options that override the inspection
    if container:
        ins = Inspector(container, no_name, pretty)
        ins.inspect()
        print(ins.format_cli())
    elif stdin:
        ins = Inspector()
        ins.pretty = pretty
        raw_json = click.get_text_stream('stdin').read()
        ins.set_facts(raw_json)
        print(ins.format_cli())
    else:
        raise click.UsageError("usage error")
Esempio n. 2
0
 def set_difficulty(self, difficulty):
 #    with self.lock:
     print('difficulty')
     self.difficulty = difficulty
     content = self.contents[self.content_id](self.difficulty)
     self.inspector = Inspector(content, display_size)
     return 'New Content Created', HTTPStatus.OK
    def __init__(self):
        self.start = self.set_attribute("start", lower_bound=2)
        self.cycles = self.set_attribute("cycles")
        self.constant = self.set_attribute("constant", is_bool=True)
        self.show_image = self.set_attribute("show_image", is_bool=True)
        self.save_image = self.set_attribute("save_image", is_bool=True)
        self.logger = self.set_attribute("logger", is_bool=True)

        self.global_command = False

        timer = time()
        print("\nGenerating objects...")

        self.object = Inspector(cycles=self.cycles,
                                start=self.start,
                                constant=self.constant,
                                logger=self.logger)

        print(f"Done ({(time() - timer):.5}s).\n")

        timer = time()
        print("Performing initial benchmark...")

        self.object.benchmark()

        print(f"Done ({(time() - timer):.5}s).\n")
Esempio n. 4
0
 def setUp(self):
     self.ins = Inspector()
     exceptionHandler = ExceptionHandler()
     sys.excepthook = exceptionHandler.handler
     self.df_timeseries = pd.DataFrame(
         data=np.random.randn(10,2),
         index=pd.date_range('2016-10-29 22:00:00', periods=10)
     )
Esempio n. 5
0
def dispatch_database_inspector(args):
    """
    Dispatch the database inspection tool
    :param args: Arguments passed to the script
    :return: None
    """
    inspector = Inspector(args)
    inspector.run()
Esempio n. 6
0
def test_inspector():
    from inspector import Inspector

    ksy_file = os.path.join(tests_dir, 'data/png.ksy')
    test_file = os.path.join(tests_dir, 'data/sample.png')

    Inspector(ksy_file, test_file, verbose=True)

    print('OK')
Esempio n. 7
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--content",
                        help="1: Point To Target" + " 2: Change Detection" +
                        " 3: Odd One Out" + " 4: Visual Search" +
                        " 5: Multiple Object Tracking" +
                        " 6: Random Dot Motion Descrimination",
                        type=int,
                        default=1)
    args = parser.parse_args()

    content_type = args.content

    if content_type == CONTENT_POINT_TO_TARGET:
        content = PointToTargetContent()
    elif content_type == CONTENT_CHANGE_DETECTION:
        content = ChangeDetectionContent()
    elif content_type == CONTENT_ODD_ONE_OUT:
        content = OddOneOutContent()
    elif content_type == CONTENT_VISUAL_SEARCH:
        content = VisualSearchContent()
    elif content_type == CONTENT_MULTIPLE_OBJECT_TRACKING:
        content = MultipleObjectTrackingContent()
    else:
        content = RandomDotMotionDiscriminationContent()

    FPS = 60
    display_size = (128 * 4 + 16, 500)
    inspector = Inspector(content, display_size)

    clock = pygame.time.Clock()
    running = True

    frame_count = 0

    if RECORDING:
        writer = MovieWriter("out.mov", inspector.display_size, FPS)

    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

        inspector.update()
        clock.tick(FPS)

        if RECORDING:
            d = inspector.get_frame()
            writer.add_frame(d)

            frame_count += 1

            if frame_count > 1000:
                running = False

    if RECORDING:
        writer.close()
Esempio n. 8
0
 def set_content(self, content_id):
     with self.lock:
         self.content_id = content_id
         content = contents[self.content_id](self.difficulty)
         self.inspector = Inspector(content, display_size)
         ret = {
             'difficulty_range': contents[content_id].difficulty_range,
             'difficulty': -1,
         }
         return flask.jsonify(ret)
Esempio n. 9
0
    def __init__(self, locals={}, debug=False):
        if not isinstance(locals, PythonNamespace):
            self.locals = dict(PythonNamespace(locals))
        else:
            self.locals = dict(locals)

        self.debug = debug
        self.trap = OutputTrap()
        self.inspector = Inspector()
        self.highlight = Highlight()
        self.index = 0
Esempio n. 10
0
 def init_webview(self):
     self.webview = webkit.WebView()
     self.web_frame = self.webview.get_main_frame()
     self.web_scroll = gtk.ScrolledWindow()
     self.web_scroll.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
     self.webview.get_settings().set_property("enable-developer-extras",
                                              True)
     self.webview.connect("document-load-finished", self.webkit_loaded_cb)
     self.webview.connect("hovering-over-link", self.over_link_cb)
     self.webview.connect_after("populate-popup", self.populate_popup_cb)
     Inspector(self.webview.get_web_inspector())
     self.web_scroll.add(self.webview)
Esempio n. 11
0
    def __init__(self, trace: dict):
        self._filename = '<script>'
        self._source = trace['source']
        self._input = trace['input'].splitlines()
        self._steps = trace['steps']

        self._inspector = Inspector()
        self._result = None

        self._current_step = 0
        self._input_index = 0
        self._missing_input = False
        self._exec_call_frame = None  # base frame (exec function call)
        self._print_cache = []
Esempio n. 12
0
    def __init__(self, parent, writer, corpus, log, color=(0, 0, 0)):
        wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
        self.sourceboard = parent
        self.writer = writer
        self.color = color
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(self.sizer)
        self.corpus = corpus
        self.name = corpus.documents[0].name
        self.log = log
        self.active = False
        self.weight = 100
        self.suggestions = self.suggest(20)
        self.inspector = False

        self.sourcetile = SourceTile(self, self.name, self.log)
        self.sizer.Add(self.sourcetile)

        self.label = wx.StaticText(self, label='Weight')
        self.label.SetForegroundColour(self.color)
        self.sizer.Add(self.label)
        self.wt_slider = wx.Slider(self, value=100, minValue=0, maxValue=100)
        self.wt_slider.Bind(wx.EVT_COMMAND_SCROLL_THUMBRELEASE,
                            self.OnWtSliderScroll)
        self.sizer.Add(self.wt_slider)
        """
		self.f_label = wx.StaticText(self, label='Frequency')
		self.f_label.SetForegroundColour(self.color)
		self.sizer.Add(self.f_label)
		self.f_slider = wx.Slider(self, value=100, minValue=0, maxValue=100)
		self.f_slider.Bind(wx.EVT_COMMAND_SCROLL_THUMBRELEASE, self.OnFreqSliderScroll)
		self.sizer.Add(self.f_slider)

		self.sig_label = wx.StaticText(self, label='Sigscore')
		self.sig_label.SetForegroundColour(self.color)
		self.sizer.Add(self.sig_label)
		self.sig_slider = wx.Slider(self, value=100, minValue=0, maxValue=100)
		self.sig_slider.Bind(wx.EVT_COMMAND_SCROLL_THUMBRELEASE, self.OnSigSliderScroll)
		self.sizer.Add(self.sig_slider)
		"""

        #self.sourcetile.header.Bind(wx.EVT_LEFT_UP, self.OnClick)

        if self.inspector:
            self.sizer.Add(
                wx.StaticLine(self, -1, wx.Point(10, 30), wx.Size(200, 30)))
            self.inspector = Inspector(self, self.corpus.documents[0])
            self.inspector.SetBackgroundColour((150, 150, 150))
            self.sizer.Add(self.inspector)
Esempio n. 13
0
    def __init__(self, builder, theme):
        webkit.WebView.__init__(self)
        providers.ProviderHandler.__init__(self, "context_page")

        # HACK: so that the panel menu works
        self.tree = self

        self.connect_events()
        self.hover = ''
        self.theme = theme
        self.loaded = False

        self.currentpage = None
        self.nowplaying = None

        self.history = []
        self.history_index = 0

        self.builder = builder
        self.setup_dnd()
        self.setup_buttons()

        self.drag_source_set(gtk.gdk.BUTTON1_MASK, self.targets,
                             gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)
        self.drag_source_set_icon_stock(gtk.STOCK_DND)

        event.add_callback(self.on_playback_start, 'playback_track_start',
                           player.PLAYER)
        event.add_callback(self.on_playback_end, 'playback_track_end',
                           player.PLAYER)
        event.add_callback(self.on_tags_parsed, 'tags_parsed', player.PLAYER)

        self.get_settings().set_property('enable-developer-extras', True)

        #FIXME: HACK! ajust zoom level for the new webkit version
        try:
            self.get_settings().get_property("enable-developer-extras")
            self.set_zoom_level(0.8)
        except:
            pass

        glib.idle_add(self.on_home_clicked)

        # javascript debugger
        inspector = Inspector(self.get_web_inspector())
Esempio n. 14
0
    def __init__(self):

        self.deck = Deck()

        self.remainingDeck = copy.deepcopy(self.deck)
        self.playedPile = PlayedPile()
        self.discardPile = DiscardPile()

        self.registeredPlayers = []
        self.currPlayer = None

        self.numCluesAvailable = 8
        self.livesRemaining = 3

        self.moveHistory = []

        self.numTurns = 0

        self.inspector = Inspector(self)
Esempio n. 15
0
 def __init__(self):
     from inspector import Inspector
     from oculoenv import PointToTargetContent, ChangeDetectionContent, OddOneOutContent, VisualSearchContent, MultipleObjectTrackingContent, RandomDotMotionDiscriminationContent
     self.contents = [
         PointToTargetContent,
         ChangeDetectionContent,
         OddOneOutContent,
         VisualSearchContent,
         MultipleObjectTrackingContent,
         RandomDotMotionDiscriminationContent,
     ]
     self.content_id = args.content
     self.difficulty = -1
     self.inspector = Inspector(
         self.contents[args.content](-1), display_size,
         model_name=args.model_name,
         use_ppo_models=args.use_ppo_models
     )
     self.lock = Lock()
Esempio n. 16
0
    def _construct_tab_view(self, web_view, url=None):

        web_view.connect("resource-request-starting", self._resource_cb)
        #web_view.connect('navigation-policy-decision-requested',self._navigation_cb)

        web_view.connect("hovering-over-link", self._hovering_over_link_cb)
        web_view.connect("populate-popup", self._populate_page_popup_cb)
        web_view.connect("load-finished", self._view_load_finished_cb)
        web_view.connect("create-web-view", self._new_web_view_request_cb)
        web_view.connect("title-changed", self._title_changed_cb)
        inspector = Inspector(web_view.get_web_inspector())

        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC
        scrolled_window.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
        scrolled_window.add(web_view)
        scrolled_window.show_all()

        # create the tab
        label = TabLabel(url, scrolled_window)
        label.connect("close", self._close_tab)
        label.show_all()

        new_tab_number = self.append_page(scrolled_window, label)
        self.set_tab_label_packing(scrolled_window, False, False,
                                   gtk.PACK_START)
        self.set_tab_label(scrolled_window, label)

        # hide the tab if there's only one
        self.set_show_tabs(self.get_n_pages() > 1)

        self.show_all()
        self.set_current_page(new_tab_number)

        # load the content
        self._hovered_uri = None
        if not url:
            web_view.load_string(ABOUT_PAGE, "text/html", "iso-8859-15",
                                 "about")
        else:
            web_view.load_uri(url)
Esempio n. 17
0
    def __init__(self, opener):
        """
		In this code, we set user-agent of this webkit view based on
		code from:

		http://nullege.com/codes/show/src%40p%40r%40PrisPy-HEAD%40PrisPy.py/33/webkit.WebView/python
		"""
        self.opener = opener
        webkit.WebView.__init__(self)
        self.set_highlight_text_matches(True)
        settings = self.get_settings()
        self.ua = settings.get_property('user-agent')
        if self.ua.find("AppleWebKit") > -1:
            # Without this, javascript will give many javascript
            # errors on item mouseover, TypeError: Result of
            # expression 'a' [null] is not an object.  in
            # its.webkitVersion
            self.ua = USER_AGENT + ' ' + self.ua[self.ua.find("AppleWebKit"):]
        else:
            self.ua = USER_AGENT
        settings.set_property('user-agent', self.ua)

        # These might possibly improve dns response?
        #settings.set_property('enable-dns-prefetching', False)
        settings.set_property('enable-site-specific-quirks', True)

        # Enable inspector:
        settings.set_property("enable-developer-extras", True)
        self._inspector = Inspector(self.get_inspector())
        self.set_settings(settings)

        # These signals are documented in webkit.WebView.__doc__
        self.connect("load-finished", self.webKitLoaded)
        self.connect("navigation-policy-decision-requested", self.webkitGo)
        self.connect("new-window-policy-decision-requested",
                     self.newWin)  #requires webkit 1.1.4
        self.connect("download-requested", self.downloadReq)
        current = os.path.dirname(os.path.realpath(__file__))
        self.injectJavascript = file(os.path.join(current, "Javascript.js"),
                                     "r").read()
Esempio n. 18
0
 def createFields(self):
     from fields import Inspector
     self.fields = Inspector(self, self.parent, -1, 'Fields' \
                                , pos=(500,300) \
                                , size=wx.Size(450,550))
     self.fields.Show(True)
Esempio n. 19
0
def cli(container, no_name, pretty, publish_all, memory_limit):

    # TODO: -i, -t, -d as added options that override the inspection
    ins = Inspector(container, no_name, pretty, publish_all, memory_limit)
    ins.inspect()
    print(ins.format_cli())
Esempio n. 20
0
 def createInspector(self):
     from inspector import Inspector
     self.inspector = Inspector(self, self.parent, -1, 'Inspector' \
                                , pos=(500,50) \
                                , size=wx.Size(450,550))
     self.inspector.Show(True)
Esempio n. 21
0
 def createSpaces(self):
     from spaces import Inspector
     self.spaces = Inspector(self, self.parent, -1, 'Spaces' \
                                , pos=(500,300) \
                                , size=wx.Size(450,550))
     self.spaces.Show(True)
Esempio n. 22
0
 def __init__(self):
     self.content_id = 0
     self.inspector = Inspector(contents[self.content_id], display_size)
     self.lock = Lock()
Esempio n. 23
0
 def swap(self, content_id):
     with self.lock:
         self.inspector = Inspector(contents[content_id], display_size)
     return 'Switched Content', HTTPStatus.OK
    def __init__(self, replication_id):  # BS: class constructor
        print('Simulation Start')
        self.running = True
        # Track current time
        self.clock = 0

        # Instantiate logger
        EXCEL_DIR = os.path.join(LOG_DIR, 'excel')
        CSV_DIR = os.path.join(LOG_DIR, 'csv')
        os.makedirs(LOG_DIR, exist_ok=True)
        os.makedirs(EXCEL_DIR, exist_ok=True)
        os.makedirs(CSV_DIR, exist_ok=True)

        OUT_PATH = os.path.join(CSV_DIR, f'rep{replication_id}.log')
        self.log = Logger(OUT_PATH)
        self.log.write_header()
        # Track number of products output in order to calculate throughput
        self.num_P1 = 0
        self.num_P2 = 0
        self.num_P3 = 0
        # Track time inspectors (either, or both) spend blocked
        self.blocked_time = 0
        # blocked inspectors list
        self.blocked_inspectors = list()
        # Setup FEL
        self.event_list = PriorityQueue()

        # Create workstations
        ws_1 = Workstation(self, 'WS1', WS1_LAM, [ComponentType.C1],
                           ProductType.P1)
        ws_2 = Workstation(self, 'WS2', WS2_LAM,
                           [ComponentType.C1, ComponentType.C2],
                           ProductType.P2)
        ws_3 = Workstation(self, 'WS3', WS3_LAM,
                           [ComponentType.C1, ComponentType.C3],
                           ProductType.P3)
        # LBS: without need to declare workstations as list
        self.workstations = [ws_1, ws_2, ws_3]

        # Create inspectors
        # LBS: ins_1_lambdas is a dict formatted as �� key: value...��
        ins_1_lambdas = {ComponentType.C1: IN1_LAM}
        ins_1 = Inspector(self, 'IN1', ins_1_lambdas, [ComponentType.C1],
                          [ws_1, ws_2, ws_3], OutputPolicy.NAIVE)

        ins_2_lambdas = {
            ComponentType.C2: IN2_LAM_C2,
            ComponentType.C3: IN2_LAM_C3
        }
        ins_2 = Inspector(self, 'IN2', ins_2_lambdas,
                          [ComponentType.C2, ComponentType.C3], [ws_2, ws_3],
                          OutputPolicy.NAIVE)
        self.inspectors = [ins_1, ins_2]

        # Generate initial events
        # These should be the two inspectors' first component selections
        self.schedule_inspection(ins_1,
                                 ins_1.generate_time(0, ins_1.component))
        self.schedule_inspection(ins_2,
                                 ins_2.generate_time(0, ins_2.component))

        # As well as an end-simulation event
        self.schedule_event(EndSimulationEvent(END_TIME))

        # Open Excel log

        self.TimeColumn = 0
        self.CurrentEventColumn = 1
        self.EventListColumn = 2
        self.Inspector1Column = 3
        self.Inspector2Column = 4
        self.WS1_C1_Q_Column = 5
        self.WS2_C1_Q_Column = 6
        self.WS2_C2_Q_Column = 7
        self.WS3_C1_Q_Column = 8
        self.WS3_C3_Q_Column = 9
        self.BLOCKED_IN1 = 10
        self.BLOCKED_IN2 = 11
        self.NUM_P1 = 12
        self.NUM_P2 = 13
        self.NUM_P3 = 14
        self.BLOCK_INS_LIST = 15
        self.WS1_BUSY = 16
        self.WS2_BUSY = 17
        self.WS3_BUSY = 18

        self.now = time.strftime("%H-%M-%S")
        self.logfile = os.path.join(EXCEL_DIR,
                                    "Log" + str(replication_id) + ".xls")
        print("new file:" + self.logfile)
        self.workbook = xlwt.Workbook(self.logfile)
        self.worksheet = self.workbook.add_sheet('log1',
                                                 cell_overwrite_ok=True)
        self.rows_old = 0
        self.write_excel_xls_append("Time", self.TimeColumn)
        self.write_excel_xls_append("CurrentEvent", self.CurrentEventColumn)
        self.write_excel_xls_append("EventList", self.EventListColumn)
        self.write_excel_xls_append("Inspector1", self.Inspector1Column)
        self.write_excel_xls_append("Inspector2", self.Inspector2Column)
        self.write_excel_xls_append("WS1_C1_Q", self.WS1_C1_Q_Column)
        self.write_excel_xls_append("WS2_C1_Q", self.WS2_C1_Q_Column)
        self.write_excel_xls_append("WS2_C2_Q", self.WS2_C2_Q_Column)
        self.write_excel_xls_append("WS3_C1_Q", self.WS3_C1_Q_Column)
        self.write_excel_xls_append("WS3_C3_Q", self.WS3_C3_Q_Column)

        self.write_excel_xls_append("blocked_IN1", self.BLOCKED_IN1)
        self.write_excel_xls_append("blocked_IN2", self.BLOCKED_IN2)
        self.write_excel_xls_append("num_P1", self.NUM_P1)
        self.write_excel_xls_append("num_P2", self.NUM_P2)
        self.write_excel_xls_append("num_P3", self.NUM_P3)
        self.write_excel_xls_append("blockInsList", self.BLOCK_INS_LIST)
        self.write_excel_xls_append("ws1Busy", self.WS1_BUSY)
        self.write_excel_xls_append("ws2Busy", self.WS2_BUSY)
        self.write_excel_xls_append("ws3Busy", self.WS3_BUSY)

        # Print initial state to console
        self.print_current_state_beforeproc(None)
        self.print_inspectors()
        self.print_workstations()
        self.print_event_list()
        self.print_current_state_afterproc(None)

        # Print initial state to console
        self.print_current_state_beforeproc(None)
        self.print_inspectors()
        self.print_workstations()
        self.print_event_list()
        self.print_current_state_afterproc(None)
Esempio n. 25
0
remove_slash = args.remove_slash
if remove_slash:
    print("Requests without last /")

discriminator = args.discriminator
if discriminator:
    print("Discriminator active")
    if request_type == "HEAD":
        print("WARNING: HEAD requests make Content inspection useless")

autodiscriminator = args.autodiscriminator
autodiscriminator_location = None
if autodiscriminator:
    print("Launching autodiscriminator")
    i = Inspector(target)
    r = i.check_this()
    if r[1] == Inspector.TEST404_URL:
        autodiscriminator_location = r[0]
        print("404 ---> 302 ----> " + autodiscriminator_location)

print("Banned response codes: %s" % " ".join(banned_response_codes))

if not extension == ['']:
    print("Extensions to probe: %s" % " ".join(extension))

uppercase = args.uppercase
if uppercase:
    print("All resource requests will be done in uppercase")

request_delay = args.request_delay
Esempio n. 26
0
def get_all_html(model_dirname, dataset, embeddings, indexer, batch_size):
    indices = np.argwhere(dataset.z == 0)
    indices = [x[0] for x in indices]
    # print((indices))
    logger.info("consider a sample of {} for htmls".format(len(indices)))
    # print(dataset.z)
    # print(dataset.w)
    num_batches = int(np.ceil(len(indices) / float(batch_size)).astype(int))
    net = torch.load(os.path.join(model_dirname, 'checkpoint.net.pt'),
                     map_location=lambda storage, y: storage)
    net_inspector = Inspector(net, embeddings)
    categorywise_all_html = defaultdict(list)

    for batch_id in range(0, num_batches):
        u.log_frequently(5, batch_id, logger.debug,
                         'processing batch {}'.format(batch_id))
        _batch_start = batch_size * batch_id
        _batch_end = batch_size * (batch_id + 1)
        batch_indices = indices[_batch_start:_batch_end]

        # print(dataset.X[_batch_start:_batch_end])
        # print(dataset.X[batch_indices])
        X0 = Variable(torch.cuda.LongTensor(dataset.X[batch_indices]))

        X5, weights, bias, ngrams_interest = net_inspector.forward_inspect(
            X0, indexer)
        yp = F.sigmoid(X5)
        yp = yp.resize(yp.size()[0])
        y_pred = yp.data.cpu().numpy()
        y_true = dataset.y[batch_indices]
        confusion_categories = get_confusion_category(y_pred, y_true, 0.5)

        for idx in range(dataset.y[batch_indices].shape[0]):
            X0_numpy = X0[idx].data.cpu().numpy()
            X5_numpy = X5[idx].data.cpu().numpy()

            logit = X5_numpy[0]
            proba = y_pred[idx]
            proba_red = hedge(2 * proba - 1, 0, 1)
            proba_blue = -hedge(2 * proba - 1, -1, 0)

            heatmap_pos, heatmap_neg = get_heatmap(idx, weights,
                                                   ngrams_interest)
            heatmap_pos = normalize_heatmap(heatmap_pos, logit, 0, 1)
            heatmap_neg = normalize_heatmap(heatmap_neg, logit, -1, 0)
            # heatmap_pos = normalize_heatmap_sigmoid(heatmap_pos, 0, 1)
            # heatmap_neg = normalize_heatmap_sigmoid(heatmap_neg, -1, 0)

            confusion_category = confusion_categories[idx]
            true_probability = HighlightedLatex.get_highlighted_word(
                '{0:.2f}'.format(y_true[idx]), r=y_true[idx], b=0)
            predicted_probability = HighlightedLatex.get_highlighted_word(
                '{0:.2f}'.format(proba), r=proba_red, b=proba_blue)
            highlighted_text = HighlightedLatex.get_highlighted_words(
                indices2words(X0_numpy), heatmap_pos, heatmap_neg)
            sample_xml = HighlightedLatex.SAMPLE_FORMAT.format(
                confusion_category=confusion_category,
                true_probability=true_probability,
                predicted_probability=predicted_probability,
                highlighted_text=highlighted_text)
            categorywise_all_html[confusion_category].append(
                (sample_xml, y_true[idx], proba))

    return categorywise_all_html
Esempio n. 27
0
 def __init__(self, klasses, klass, module):
     super(DetailPageRenderer, self).__init__(klasses)
     self.klass = klass
     self.module = module
     self.inspector = Inspector(self.klass, self.module)
import sys
import os
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

sys.path.append(
    os.path.dirname(os.path.realpath(__file__)) + '/../../anki-web-browser')
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + '/../src')

import anki_web_browser.browser as brw
from controller import Controller
from inspector import Inspector


def wiki(self):
    print('Load')
    self.load(QUrl('https://en.wikipedia.org'))


if __name__ == '__main__':
    print('Running Qt App')
    app = QApplication(sys.argv)
    web = brw.AwBrowser(None)
    # ctr = Controller(None)
    web.open('https://www.google.com/?q={}', 'my app test')
    # ctr.setupBindings(web._web)
    insp = Inspector(web)
    insp.inspect(web._web)
    web.show()
    sys.exit(app.exec_())
Esempio n. 29
0
def cli(container, no_name, pretty):

    # TODO: -i, -t, -d as added options that override the inspection
    ins = Inspector(container, no_name, pretty)
    ins.inspect()
    print(ins.format_cli())
Esempio n. 30
0
                    action='store_true',
                    help="Use this option to run the inspector")
    ap.add_argument("-c",
                    "--clear",
                    required=False,
                    action='store_true',
                    help="Clear the branches information file.")

    args = ap.parse_args()

    if args.clear:
        try:
            shutil.rmtree(Constants.dir_logs)
            shutil.rmtree(Constants.dir_bank)
            print("bank/ and logs/ directories were removed.")
        except FileNotFoundError:
            print("directories do not exist. They were already removed.")

        exit(0)

    if args.bank and args.inspector:
        raise "You must only use one option."
    elif args.bank:
        branch = Bank()
        branch.run()
    elif args.inspector:
        inspector = Inspector()
        inspector.run()
    else:
        raise "Use one of the options (-b or -i)"