Beispiel #1
0
    def write_statistics(self):
        if not release:
            log.info("Not sending usage statistics (non-release version of Orange detected).")
            return

        if not config.settings()["error-reporting/send-statistics"]:
            log.info("Not sending usage statistics (preferences setting).")
            return

        statistics = {
            "Date": str(datetime.now().date()),
            "Orange Version": full_version,
            "Operating System": platform.system() + " " + platform.release(),
            "Session": {
                "Quick Menu Search": self.quick_menu_actions,
                "Toolbox Click": self.toolbox_clicks,
                "Toolbox Drag": self.toolbox_drags,
                "Widget Extension": self.widget_extensions
            }
        }

        if os.path.isfile(statistics_path):
            with open(statistics_path) as f:
                data = json.load(f)
        else:
            data = []

        data.append(statistics)

        with open(statistics_path, 'w') as f:
            json.dump(data, f)
Beispiel #2
0
    def log_node_added(self, widget_name, extended_widget=None):
        if not config.settings()["error-reporting/send-statistics"]:
            return

        if self.__node_addition_type == UsageStatistics.NodeAddMenu:

            self.quick_menu_actions.append({
                "Widget Name":
                widget_name,
                "Query":
                UsageStatistics.last_search_query,
            })

        elif self.__node_addition_type == UsageStatistics.NodeAddClick:

            self.toolbox_clicks.append({
                "Widget Name": widget_name,
            })

        elif self.__node_addition_type == UsageStatistics.NodeAddDrag:

            self.toolbox_drags.append({
                "Widget Name": widget_name,
            })

        elif self.__node_addition_type == UsageStatistics.NodeAddExtendFromSink:

            self.widget_extensions.append({
                "Widget Name":
                widget_name,
                "Extended Widget":
                extended_widget,
                "Direction":
                "FROM_SINK",
                "Query":
                UsageStatistics.last_search_query,
            })

        elif self.__node_addition_type == UsageStatistics.NodeAddExtendFromSource:

            self.widget_extensions.append({
                "Widget Name":
                widget_name,
                "Extended Widget":
                extended_widget,
                "Direction":
                "FROM_SOURCE",
                "Query":
                UsageStatistics.last_search_query,
            })

        else:
            log.warning("Invalid usage statistics state; "
                        "attempted to log node before setting node type.")
Beispiel #3
0
def setup_notifications():
    settings = config.settings()

    # If run for the fifth time, prompt short survey
    show_survey = settings["startup/show-short-survey"] and \
                  settings["startup/launch-count"] >= 5
    if show_survey:
        surveyDialogButtons = NotificationWidget.Ok | NotificationWidget.Close
        surveyDialog = NotificationWidget(
            icon=QIcon(gui.resource_filename("icons/information.png")),
            title="Survey",
            text="We want to understand our users better.\n"
            "Would you like to take a short survey?",
            standardButtons=surveyDialogButtons)

        def handle_survey_response(button):
            if surveyDialog.buttonRole(
                    button) == NotificationWidget.AcceptRole:
                success = QDesktopServices.openUrl(
                    QUrl("https://orange.biolab.si/survey/short.html"))
                settings["startup/show-short-survey"] = not success
            elif surveyDialog.buttonRole(
                    button) == NotificationWidget.RejectRole:
                settings["startup/show-short-survey"] = False

        surveyDialog.clicked.connect(handle_survey_response)

        NotificationOverlay.registerNotification(surveyDialog)

    # data collection permission
    if not settings["error-reporting/permission-requested"]:
        permDialogButtons = NotificationWidget.Ok | NotificationWidget.Close
        permDialog = NotificationWidget(
            icon=QIcon(gui.resource_filename("../../distribute/icon-48.png")),
            title="Anonymous Usage Statistics",
            text="Do you wish to opt-in to sharing "
            "statistics about how you use Orange?\n"
            "All data is anonymized and used "
            "exclusively for understanding how users "
            "interact with Orange.",
            standardButtons=permDialogButtons)
        btnOK = permDialog.button(NotificationWidget.AcceptRole)
        btnOK.setText("Allow")

        def handle_permission_response(button):
            if permDialog.buttonRole(button) != permDialog.DismissRole:
                settings["error-reporting/permission-requested"] = True
            if permDialog.buttonRole(button) == permDialog.AcceptRole:
                settings["error-reporting/send-statistics"] = True

        permDialog.clicked.connect(handle_permission_response)

        NotificationOverlay.registerNotification(permDialog)
Beispiel #4
0
    def write_statistics(self):
        if not release:
            log.info(
                "Not sending usage statistics (non-release version of Orange detected)."
            )
            return

        if not config.settings()["error-reporting/send-statistics"]:
            log.info("Not sending usage statistics (preferences setting).")
            return

        statistics = {
            "Date": str(datetime.now().date()),
            "Orange Version": full_version,
            "Operating System": platform.system() + " " + platform.release(),
            "Session": {
                "Quick Menu Search": self.quick_menu_actions,
                "Toolbox Click": self.toolbox_clicks,
                "Toolbox Drag": self.toolbox_drags,
                "Widget Extension": self.widget_extensions
            }
        }

        if os.path.isfile(statistics_path):
            with open(statistics_path) as f:
                data = json.load(f)
        else:
            data = []

        data.append(statistics)

        def store_data(d):
            with open(statistics_path, 'w') as f:
                json.dump(d, f)

        try:
            r = requests.post(server_url, files={'file': json.dumps(data)})
            if r.status_code != 200:
                log.warning(
                    "Error communicating with server while attempting to send "
                    "usage statistics.")
                store_data(data)
                return
            # success - wipe statistics file
            log.info("Usage statistics sent.")
            with open(statistics_path, 'w') as f:
                json.dump([], f)
        except (ConnectionError, requests.exceptions.RequestException):
            log.warning(
                "Connection error while attempting to send usage statistics.")
            store_data(data)
Beispiel #5
0
    def write_statistics(self):
        if not release:
            log.info("Not sending usage statistics (non-release version of Orange detected).")
            return

        if not config.settings()["error-reporting/send-statistics"]:
            log.info("Not sending usage statistics (preferences setting).")
            return

        statistics = {
            "Date": str(datetime.now().date()),
            "Orange Version": full_version,
            "Operating System": platform.system() + " " + platform.release(),
            "Session": {
                "Quick Menu Search": self.quick_menu_actions,
                "Toolbox Click": self.toolbox_clicks,
                "Toolbox Drag": self.toolbox_drags,
                "Widget Extension": self.widget_extensions
            }
        }

        if os.path.isfile(statistics_path):
            with open(statistics_path) as f:
                data = json.load(f)
        else:
            data = []

        data.append(statistics)

        def store_data(d):
            with open(statistics_path, 'w') as f:
                json.dump(d, f)

        try:
            r = requests.post(server_url, files={'file': json.dumps(data)})
            if r.status_code != 200:
                log.warning("Error communicating with server while attempting to send "
                            "usage statistics.")
                store_data(data)
                return
            # success - wipe statistics file
            log.info("Usage statistics sent.")
            with open(statistics_path, 'w') as f:
                json.dump([], f)
        except (ConnectionError, requests.exceptions.RequestException):
            log.warning("Connection error while attempting to send usage statistics.")
            store_data(data)
Beispiel #6
0
 def send_statistics(self):
     if release and config.settings()["error-reporting/send-statistics"]:
         if os.path.isfile(statistics_path):
             with open(statistics_path) as f:
                 data = json.load(f)
             try:
                 r = requests.post(server_url, files={'file': json.dumps(data)})
                 if r.status_code != 200:
                     log.warning("Error communicating with server while attempting to send "
                                 "usage statistics.")
                     return
                 # success - wipe statistics file
                 log.info("Usage statistics sent.")
                 with open(statistics_path, 'w') as f:
                     json.dump([], f)
             except (ConnectionError, requests.exceptions.RequestException):
                 log.warning("Connection error while attempting to send usage statistics.")
Beispiel #7
0
    def log_node_added(self, widget_name, extended_widget=None):
        if not config.settings()["error-reporting/send-statistics"]:
            return

        if self.__node_addition_type == UsageStatistics.NodeAddMenu:

            self.quick_menu_actions.append({
                "Widget Name": widget_name,
                "Query": UsageStatistics.last_search_query,
            })

        elif self.__node_addition_type == UsageStatistics.NodeAddClick:

            self.toolbox_clicks.append({
                "Widget Name": widget_name,
            })

        elif self.__node_addition_type == UsageStatistics.NodeAddDrag:

            self.toolbox_drags.append({
                "Widget Name": widget_name,
            })

        elif self.__node_addition_type == UsageStatistics.NodeAddExtendFromSink:

            self.widget_extensions.append({
                "Widget Name": widget_name,
                "Extended Widget": extended_widget,
                "Direction": "FROM_SINK",
                "Query": UsageStatistics.last_search_query,
            })

        elif self.__node_addition_type == UsageStatistics.NodeAddExtendFromSource:

            self.widget_extensions.append({
                "Widget Name": widget_name,
                "Extended Widget": extended_widget,
                "Direction": "FROM_SOURCE",
                "Query": UsageStatistics.last_search_query,
            })

        else:
            log.warning("Invalid usage statistics state; "
                        "attempted to log node before setting node type.")