Пример #1
0
class ZFeedbackBackgroundTask(ZBackgroundTask):

    def __init__(self):
        self.endpoint = None
        self.customAttributes = {}
        self.connection = None

        ZBackgroundTask.__init__(self)
    # end __init__()

    def initialize(self, endpoint, feedback, version):
        self.endpoint = endpoint
        self.feedback = feedback
        self.version = version
        self.setName(_extstr(u"feedbackimpl.SendingFeedback")) #$NON-NLS-1$
        self.setNumWorkUnits(2)
    # end initialize()

    def getCustomAttributes(self):
        return self.customAttributes
    # end getCustomAttributes()

    def setCustomAttributes(self, attributeMap):
        self.customAttributes = attributeMap
    # end setCustomAttributes()

    def isResumable(self):
        return False
    # end isResumable()

    def _doCancel(self):
        if self.connection:
            self.connection.close()
    # end _doCancel()

    def _run(self):
        self._incrementWork(_extstr(u"feedbackimpl.FeedbackInformationGathered_"), 1, True) #$NON-NLS-1$
        self.connection = ZSimpleXmlHTTPRequest(self.endpoint)

        postData = {
                u"name" : u"N/A", #$NON-NLS-2$ #$NON-NLS-1$
                u"email" : self.feedback.getEmail(), #$NON-NLS-1$
                u"title" : self.feedback.getSubject(), #$NON-NLS-1$
                u"description" : self.feedback.getFeedback(), #$NON-NLS-1$
                u"timestamp" : unicode(self.feedback.getTimestamp()), #$NON-NLS-1$
                u"version" : self.version.getFullVersionString(), #$NON-NLS-1$
                u"blogplatform" : u"N/A", #$NON-NLS-1$ #$NON-NLS-2$
                u"reporttype" : self.feedback.getType(), #$NON-NLS-1$
                u"pubsites" : u"N/A", #$NON-NLS-1$ #$NON-NLS-2$
        }
        if self.connection.send(postData):
            self.connection.getResponse()
        else:
            raise ZException(_extstr(u"feedbackimpl.SendingFeedbackFailed")) #$NON-NLS-1$
        self._incrementWork(_extstr(u"feedbackimpl.FeedbackSent"), 1, True) #$NON-NLS-1$
Пример #2
0
 def convertProductLink(self, productUrl, zoundryServiceId):
     postData = self._getAddProductPostDataForUrl(productUrl, zoundryServiceId)
     headers = {
         u"Content-Type" : u"text/xml", #$NON-NLS-2$ #$NON-NLS-1$
         u"Content-Length" : u"%d" % len(postData) #$NON-NLS-1$ #$NON-NLS-2$
     }
     request = ZSimpleXmlHTTPRequest(ADD_PRODUCT_ENDPOINT, headers, True)
     if request.send(postData):
         dom = request.getResponse()
         respCode = dom.selectSingleNodeText(u"/Response/Status/Code") #$NON-NLS-1$
         if respCode == u"200": #$NON-NLS-1$
             return dom.selectSingleNodeText(u"/Response/AddProductsResponse/Product/ProxyUrl").strip() #$NON-NLS-1$
     return None
Пример #3
0
 def getLatestVersionInfo(self):
     appModel = getApplicationModel()
     build = unicode(appModel.getVersion().getBuild())
     userProfile = appModel.getUserProfile()
     userPrefs = userProfile.getPreferences()
     guid = userPrefs.getUserPreference(IZAppUserPrefsKeys.GUID, u"") #$NON-NLS-1$
     url = self.versionXmlUrl % (guid, build)
     self.logger.debug(u"Getting latest version at URL: %s" % url) #$NON-NLS-1$
     request = ZSimpleXmlHTTPRequest(url)
     try:
         if request.send():
             return ZLatestVersionInfo(request.getResponse())
     except Exception, e:
         self.logger.exception(e)
Пример #4
0
 def convertProductLink(self, productUrl, zoundryServiceId):
     postData = self._getAddProductPostDataForUrl(productUrl,
                                                  zoundryServiceId)
     headers = {
         u"Content-Type": u"text/xml",  #$NON-NLS-2$ #$NON-NLS-1$
         u"Content-Length": u"%d" % len(postData)  #$NON-NLS-1$ #$NON-NLS-2$
     }
     request = ZSimpleXmlHTTPRequest(ADD_PRODUCT_ENDPOINT, headers, True)
     if request.send(postData):
         dom = request.getResponse()
         respCode = dom.selectSingleNodeText(
             u"/Response/Status/Code")  #$NON-NLS-1$
         if respCode == u"200":  #$NON-NLS-1$
             return dom.selectSingleNodeText(
                 u"/Response/AddProductsResponse/Product/ProxyUrl").strip(
                 )  #$NON-NLS-1$
     return None