<commit_before># Copyright (c) 2015 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.

from UM.Extension import Extension
from UM.Application import Application
from UM.Preferences import Preferences
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Scene.SceneNode import SceneNode
from UM.Message import Message
from UM.i18n import i18nCatalog
from UM.Logger import Logger
from UM.Platform import Platform
from UM.Qt.Duration import DurationFormat
from UM.Job import Job

import platform
import math
import urllib.request
import urllib.parse
import ssl

catalog = i18nCatalog("cura")

class SliceInfoJob(Job):
    data = None
    url = None

    def __init__(self, url, data):
        super.__init__(self)
        self.url = url
        self.data = data

    def run(self):
        if not self.url or not self.data:
            Logger.log("e", "URL or DATA for sending slice info was not set!")
            return

        # Submit data
        kwoptions = {"data" : self.data,
                     "timeout" : 5
                     }

        if Platform.isOSX():
            kwoptions["context"] = ssl._create_unverified_context()

        try:
            f = urllib.request.urlopen(self.url, **kwoptions)
            Logger.log("i", "Sent anonymous slice info to %s", self.url)
            f.close()
        except urllib.error.HTTPError as http_exception:
            Logger.log("e", "An exception occurred while trying to send slice information: %s" %(repr(http_exception)))
        except Exception: # Includes urllib.error.HTTPError, was discussed to be handled like any other exception 
            Logger.logException("e", "An exception occurred while trying to send slice information")

##      This Extension runs in the background and sends several bits of information to the Ultimaker servers.
#       The data is only sent when the user in question gave permission to do so. All data is anonymous and
#       no model files are being sent (Just a SHA256 hash of the model).
class SliceInfo(Extension):
    info_url = "https://stats.youmagine.com/curastats/slice"<commit_msg>CURA-1923: Just something I missed Forgot to remove 'self' from 'super().__init__()'<commit_after># Copyright (c) 2015 <NAME>.
# Cura is released under the terms of the AGPLv3 or higher.

from UM.Extension import Extension
from UM.Application import Application
from UM.Preferences import Preferences
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Scene.SceneNode import SceneNode
from UM.Message import Message
from UM.i18n import i18nCatalog
from UM.Logger import Logger
from UM.Platform import Platform
from UM.Qt.Duration import DurationFormat
from UM.Job import Job

import platform
import math
import urllib.request
import urllib.parse
import ssl

catalog = i18nCatalog("cura")

class SliceInfoJob(Job):
    data = None
    url = None

    def __init__(self, url, data):
        super().__init__()
        self.url = url
        self.data = data

    def run(self):
        if not self.url or not self.data:
            Logger.log("e", "URL or DATA for sending slice info was not set!")
            return

        # Submit data
        kwoptions = {"data" : self.data,
                     "timeout" : 5
                     }

        if Platform.isOSX():
            kwoptions["context"] = ssl._create_unverified_context()

        try:
            f = urllib.request.urlopen(self.url, **kwoptions)
            Logger.log("i", "Sent anonymous slice info to %s", self.url)
            f.close()
        except urllib.error.HTTPError as http_exception:
            Logger.log("e", "An exception occurred while trying to send slice information: %s" %(repr(http_exception)))
        except Exception: # Includes urllib.error.HTTPError, was discussed to be handled like any other exception 
            Logger.logException("e", "An exception occurred while trying to send slice information")

##      This Extension runs in the background and sends several bits of information to the Ultimaker servers.
#       The data is only sent when the user in question gave permission to do so. All data is anonymous and
#       no model files are being sent (Just a SHA256 hash of the model).
class SliceInfo(Extension):
    info_url = "https://stats.youmagine.com/curastats/slice"
{'fraction_non_alphanumeric': 0.07911683532658693, 'fraction_numerical': 0.0078196872125115, 'mean_word_length': 2.8657777777777778, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3612701', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1179, 'n_words': 456}