Пример #1
0
def main():

    d = getDateTime()

    # Global app
    app = QApplication(sys.argv)

    QApplication.setQuitOnLastWindowClosed(False)
    qIcon = QIcon('icons/shotty.png')
    app.setWindowIcon(qIcon)

    shotty = ShottyFullscreen()

    showNotification('Shotty', 'Running in the background')

    tray = QSystemTrayIcon()
    if tray.isSystemTrayAvailable():
        tray.setIcon(QIcon('icons/shotty.png'))
        tray.setVisible(True)
        tray.show()

        # Add a menu
        trayMenu = QMenu()
        region_screenshot_action = QAction(QIcon("icons/screenshot.png"),
                                           'Take region screenshot')
        full_screenshot_action = QAction(QIcon("icons/screenshot.png"),
                                         'Take screenshot')
        settings_action = QAction(QIcon("icons/settings.png"), 'Settings')
        about_action = QAction(QIcon("icons/info.png"), 'About')
        exit_action = QAction(QIcon("icons/exit.png"), 'Exit Shoty')

        exit_action.triggered.connect(app.exit)
        about_action.triggered.connect(shotty.showShottyAboutWindow)
        region_screenshot_action.triggered.connect(shotty.initUI)
        # We need to pass checked because connect passes
        # a bool arg as first param
        full_screenshot_action.triggered.connect(
            lambda checked, date=getDateTime(
            ), x1=-1, y1=-1, x2=-1, y2=-1, im=screenshot(
            ): shotty.saveScreenShot(date, x1, y1, x2, y2, im=im[:, :, :3]))
        trayMenu.addAction(region_screenshot_action)
        trayMenu.addAction(full_screenshot_action)
        trayMenu.addAction(settings_action)
        trayMenu.addAction(about_action)
        trayMenu.addAction(exit_action)

        tray.setContextMenu(trayMenu)
    else:
        print("[ERROR] Can't instantiate tray icon")

    sys.exit(app.exec_())
Пример #2
0
def testSSL(testSSLPath, uri, testSSLoutputFile, sev_threshold):
    #output = subprocess.check_output("testssl.sh --jsonfile " + jsonFile + host)
    print("[Info] Please wait currently running SSL/TLS tests...")
#     # get current date and time 
#     currentDateTime = datetime.datetime.now()
#     # append the file with current date and time
#     outputFile = outputFile + "_" + currentDateTime.strftime("%Y-%m-%d_%H-%M-%S") + ".json"
    testSSLoutputFile = utils.getDateTime(testSSLoutputFile, "json")
    p1 = subprocess.Popen([testSSLPath, "--jsonfile", testSSLoutputFile, uri], stdout=subprocess.PIPE)   
    # Run the command
    output = p1.communicate()[0]
    print (output)
    csvdata = createCSVfindings(testSSLoutputFile,sev_threshold) 
    htmlReportName = utils.getDateTime(reportName, "html") 
    details = [deviceType,version,uri] 
    utils.createHTMLReport(csvdata, htmlReportName, reportTitle, details)
Пример #3
0
 def encodeValue(self, value):
     """Return a string-encoded ``value``."""
     if value:
         value = utils.getDateTime(value)
         # LE byteorder
         _rv = struct.pack("<2I", value.toordinal() + self.JDN_GDN_DIFF,
             (value.hour * 3600 + value.minute * 60 + value.second) * 1000)
     else:
         _rv = "\0" * self.length
     assert len(_rv) == self.length
     return _rv
Пример #4
0
    def showCroppedMenu(self, e):
        menu = QMenu()
        save_crop_action = QAction(QIcon("icons/save.png"), "Save region",
                                   self)
        saveAs_crop_action = QAction(QIcon("icons/save-as.png"),
                                     "Save region as..", self)
        clipboard_crop_action = QAction(QIcon("icons/copy-clipboard.png"),
                                        "Copy region to clipboard", self)
        cancel_action = QAction(QIcon("icons/close-window.png"), "Cancel",
                                self)
        exit_action = QAction(QIcon("icons/exit.png"), "Exit", self)

        menu.addAction(save_crop_action)
        menu.addAction(saveAs_crop_action)
        menu.addAction(clipboard_crop_action)
        menu.addAction(cancel_action)
        menu.addAction(exit_action)

        action = menu.exec_(self.mapToGlobal(QPoint(e.x(), e.y())))

        if action == save_crop_action:
            datetime = getDateTime()
            self.saveScreenShot(datetime, self.rect_x1, self.rect_y1, e.x(),
                                e.y())
            self.closeToBackground()
        elif action == saveAs_crop_action:
            datetime = getDateTime()
            filename = self.saveFileDialog(datetime)
            if filename:
                self.saveScreenShot(filename, self.rect_x1, self.rect_y1,
                                    e.x(), e.y())
                self.closeToBackground()
        elif action == clipboard_crop_action:
            self.copyToClipboard(self.rect_x1, self.rect_y1, e.x(), e.y())
            self.closeToBackground()
        elif action == cancel_action:
            return
        elif action == exit_action:
            self.closeToBackground()
Пример #5
0
    def showFullscreenshotMenu(self, e):
        menu = QMenu()

        save_full_action = QAction(QIcon("icons/save.png"), "Save", self)
        saveAs_full_action = QAction(QIcon("icons/save.png"), "Save as..",
                                     self)
        clipboard_full_action = QAction(QIcon("icons/copy-clipboard.png"),
                                        "Copy to clipboard", self)
        cancel_action = QAction(QIcon("icons/close-window.png"), "Cancel",
                                self)
        exit_action = QAction(QIcon("icons/exit.png"), "Exit", self)

        menu.addAction(save_full_action)
        menu.addAction(saveAs_full_action)
        menu.addAction(clipboard_full_action)
        menu.addAction(cancel_action)
        menu.addAction(exit_action)

        action = menu.exec_(self.mapToGlobal(QPoint(e.x(), e.y())))

        self.overlay.active = True

        if action == save_full_action:
            datetime = getDateTime()
            self.saveScreenShot(datetime, -1, -1, -1, -1)
            self.closeToBackground()
        elif action == saveAs_full_action:
            datetime = getDateTime()
            filename = self.saveFileDialog(datetime)
            if filename:
                self.saveScreenShot(filename, -1, -1, -1, -1)
                self.closeToBackground()
        elif action == clipboard_full_action:
            self.copyToClipboard(-1, -1, -1, -1)
        elif action == cancel_action:
            return
        elif action == exit_action:
            self.closeToBackground()
Пример #6
0
def saveFile(frame_origin, frame, left, top, right, bottom):
    folder_name = utils.getDateStr()
    file_name = utils.getDateTime()

    out_folder = os.path.join(folder_out, folder_name)
    utils.createFolder(out_folder)  #check if not exist then creategit

    origin_file = os.path.join(out_folder, "{}.jpeg".format(file_name))
    cv.imwrite(origin_file, frame_origin)

    out_file = os.path.join(out_folder, "{}_detect.jpeg".format(file_name))
    cv.imwrite(out_file, frame)

    crop = frame_origin[top:bottom, left:right]
    crop_file = os.path.join(out_folder, "{}_crop.jpeg".format(file_name))
    cv.imwrite(crop_file, crop)

    print("Saved: " + origin_file)
    lpr_ai4thai(origin_file, out_file, crop_file)
Пример #7
0
config = tf.ConfigProto(device_count={'GPU': gpu_id})
config.gpu_options.allow_growth = allow_memory_growth

if not save_seg:
    save_raw = save_stitched = False

classes = tuple(range(n_classes))

with tf.Session(config=config) as sess:
    init = tf.global_variables_initializer()
    init.run()

    if not os.path.isdir(save_path):
        os.makedirs(save_path)
    log_fname = os.path.join(save_path, 'log_{:s}.txt'.format(getDateTime()))

    if save_seg:
        print_and_write('Saving segmentation results to: {}'.format(save_path),
                        log_fname)
    else:
        print_and_write('Not saving segmentation results', log_fname)

    print_and_write('Saving log to: {}'.format(log_fname), log_fname)

    save_path_raw = os.path.join(save_path, 'raw')
    if save_raw:
        print_and_write('Saving raw labels to: {}\n'.format(save_path_raw))
        if not os.path.isdir(save_path_raw):
            os.makedirs(save_path_raw)