예제 #1
0
    def update(self, ss, when):
        strLine = Long.toString(when.getTimeInMillis()).encode('utf-8')
        for s in bricSymbols:
            if s in ss:
                strLine = strLine + ',' \
                    + Double.toString(market.getLastPrice(0,s+'-OPEN'))\
                            .encode('utf-8') + ','\
                    + Double.toString(market.getLastPrice(0,s+'-HIGH'))\
                            .encode('utf-8') + ',' \
                    + Double.toString(market.getLastPrice(0,s+'-LOW'))\
                            .encode('utf-8') + ','\
                    + Double.toString(market.getLastPrice(0,s+'-CLOSE'))\
                            .encode('utf-8') + ','\
                    + Long.toString(market.getLastVolume(0,s))\
                            .encode('utf-8')
            else:
                strLine = strLine + ',-,-,-,-,-'
       
        if 'XAG' in ss:
            strLine = strLine + ',' \
                + Double.toString(market.getLastPrice(0,'XAG-OPEN'))\
                        .encode('utf-8') + ','\
                + Double.toString(market.getLastPrice(0,'XAG-HIGH'))\
                        .encode('utf-8') + ',' \
                + Double.toString(market.getLastPrice(0,'XAG-LOW'))\
                        .encode('utf-8') + ','\
                + Double.toString(market.getLastPrice(0,'XAG-CLOSE'))\
                        .encode('utf-8') + ','\
                + Long.toString(market.getLastVolume(0,'XAG'))\
                        .encode('utf-8')
        else:
            strLine = strLine + ',-,-,-,-,-'
 
        print strLine
예제 #2
0
    def update(self, ss, when):
        strLine = Long.toString(when.getTimeInMillis()).encode('utf-8')
        if 'X' in ss:
            strLine = strLine + ',' \
                + Double.toString(market.getLastPrice(0,'X-OPEN'))\
                        .encode('utf-8') + ','\
                + Double.toString(market.getLastPrice(0,'X-HIGH'))\
                        .encode('utf-8') + ',' \
                + Double.toString(market.getLastPrice(0,'X-LOW'))\
                        .encode('utf-8') + ','\
                + Double.toString(market.getLastPrice(0,'X-CLOSE'))\
                        .encode('utf-8') + ','\
                + Long.toString(market.getLastVolume(0,'X'))\
                        .encode('utf-8')
        else:
            strLine = strLine + ',-,-,-,-,-'

        if 'Y' in ss:
            strLine = strLine + ',' \
                + Double.toString(market.getLastPrice(0,'Y-OPEN'))\
                        .encode('utf-8') + ','\
                + Double.toString(market.getLastPrice(0,'Y-HIGH'))\
                        .encode('utf-8') + ',' \
                + Double.toString(market.getLastPrice(0,'Y-LOW'))\
                        .encode('utf-8') + ','\
                + Double.toString(market.getLastPrice(0,'Y-CLOSE'))\
                        .encode('utf-8') + ','\
                + Long.toString(market.getLastVolume(0,'Y'))\
                        .encode('utf-8')
        else:
            strLine = strLine + ',-,-,-,-,-'

        print strLine
예제 #3
0
 def update(self, ss, when):
     strLine = Long.toString(when.getTimeInMillis()).encode('utf-8')
     strLine = strLine + ',' \
         + Double.toString(market.getLastPrice(0,'XAG-OPEN'))\
                 .encode('utf-8') + ','\
         + Double.toString(market.getLastPrice(0,'XAG-HIGH'))\
                 .encode('utf-8') + ',' \
         + Double.toString(market.getLastPrice(0,'XAG-LOW'))\
                 .encode('utf-8') + ','\
         + Double.toString(market.getLastPrice(0,'XAG-CLOSE'))\
                 .encode('utf-8') + ','\
         + Long.toString(market.getLastVolume(0,'XAG'))\
                 .encode('utf-8')
     print strLine
예제 #4
0
    def __activate__(self, context):
        self.velocityContext = context
        self.log = self.vc("log")
        self.systemConfig = self.vc("systemConfig")
        self.session = self.vc("sessionState")
        self.response = self.vc("response")
        self.request = self.vc("request")
        self.msg = ""
        self.appId = None

        uri = URLDecoder.decode(self.request.getAttribute("RequestURI"))
        matches = re.match("^(.*?)/(.*?)/(.*?)/(.*?)/(.*?)$", uri)
        if matches and matches.group(5):
            self.appId = matches.group(5)

        if not self.appId:
            self.msg = "No appId specified"
            self.log.error(self.msg)
            return
        self.log.debug("Getting configuration for: " + self.appId)
        self.consumerName = self.systemConfig.getString(
            None, "authserver", self.appId, "name")
        self.sharedKey = self.systemConfig.getString(None, "authserver",
                                                     self.appId, "sharedKey")
        self.aud = self.systemConfig.getString(None, "authserver", self.appId,
                                               "aud")
        self.iss = self.systemConfig.getString(None, "authserver", self.appId,
                                               "iss")
        self.expiry = self.systemConfig.getInteger(None, "authserver",
                                                   self.appId, "expiry")
        self.logoutUrl = self.systemConfig.getString(None, "authserver",
                                                     self.appId, "logoutUrl")
        logout = self.request.getParameter("logout")
        if logout == "1":
            self.session.invalidate()
            self.response.sendRedirect(self.logoutUrl)
            return
        if not self.consumerName:
            self.msg = "Invalid configuration, no app name"
            self.log.error(self.msg)
            return
        if not self.sharedKey:
            self.msg = "Invalid shared Key"
            self.log.error(self.msg)
            return
        if not self.aud:
            self.msg = "Invalid aud"
            self.log.error(self.msg)
            return
        if not self.iss:
            self.msg = "Invalid iss"
            self.log.error(self.msg)
            return
        if not self.expiry:
            self.msg = "Invalid expiry"
            self.log.error(self.msg)
            return

        # Because we don't trust the configuration
        current_user = self.vc("page").authentication.get_username()
        isAdmin = self.vc("page").authentication.is_admin()
        # Admin only...
        if not isAdmin:
            self.msg = "Sorry, this page is only for administrators."
            self.log.error(self.msg)
            return
        # Get the roles...
        typ = "[\"" + "\",\"".join(
            self.vc("page").authentication.get_roles_list()) + "\"]"
        # Generating signature...
        dtNow = Date().getTime()
        now = dtNow / 1000
        iat = now
        nbf = now - 1
        exp = now + self.expiry
        secRandom = SecureRandom()
        jti = Long.toString(dtNow) + "_" + Integer.toString(
            secRandom.nextInt())
        payload = Payload(
            '{"iss":"%s",  "sub":"%s", "aud":"%s", "iat":"%s", "nbf":"%s", "exp":"%s", "jti":"%s", "typ":%s}'
            % (self.iss, current_user, self.aud, iat, nbf, exp, jti, typ))
        jwsHeader = JWSHeader(JWSAlgorithm.HS256)
        macSigner = MACSigner(self.sharedKey)
        jwsObject = JWSObject(jwsHeader, payload)
        jwsObject.sign(macSigner)
        self.jws = jwsObject.serialize()
예제 #5
0
# STATUS: Draft

from psdi.mbo import MboRemote
from psdi.mbo import MboConstants
from psdi.mbo import MboSetRemote
from psdi.server import MXServer
from java.lang import String
from java.lang import Long

contractMboSet = mbo.getMboSet(
    "EX2_PURCHVIEW"
)  #Relationship to fetch the contractid for the previously revised latest Approved Contract
# If new contract it would fetch zero
count2 = contractMboSet.count()
if (count2 > 0):
    contractid = Long.toString(LCONTRACTID)
    mbosetESCTRACK = MXServer.getMXServer().getMboSet("ESCREPEATTRACK",
                                                      mbo.getUserInfo())
    notifycount1 = mbosetESCTRACK.count()
    mbosetESCTRACK.setWhere(
        " OWNERID = '" + contractid +
        "'AND OBJECTNAME ='PURCHVIEW' and ESCALATION ='EX2PURCTREXP' ")
    mbosetESCTRACK.reset()
    notifycount = mbosetESCTRACK.count(
    )  #Saves the number of notifications sent for this contractid
    if (notifycount == 3):
        mbo.setValue("EX2EMAILFLAG", '3', MboConstants.NOACCESSCHECK)
        mbo.setValue("EX2ENDDATE", ENDDATE, MboConstants.NOACCESSCHECK)
    elif (notifycount == 2):
        mbo.setValue("EX2EMAILFLAG", '2', MboConstants.NOACCESSCHECK)
        mbo.setValue("EX2ENDDATE", ENDDATE, MboConstants.NOACCESSCHECK)
 def __activate__(self, context):
     self.velocityContext = context
     self.log = self.vc("log")
     self.systemConfig = self.vc("systemConfig")
     self.session = self.vc("sessionState")
     self.response = self.vc("response")
     self.request = self.vc("request")
     self.msg = ""
     self.appId = None
     
     uri = URLDecoder.decode(self.request.getAttribute("RequestURI"))
     matches = re.match("^(.*?)/(.*?)/(.*?)/(.*?)/(.*?)$", uri)
     if matches and matches.group(5):    
         self.appId = matches.group(5)
         
     if not self.appId:
         self.msg = "No appId specified"
         self.log.error(self.msg)
         return
     self.log.debug("Getting configuration for: " + self.appId)
     self.consumerName = self.systemConfig.getString(None, "authserver", self.appId, "name")
     self.sharedKey = self.systemConfig.getString(None, "authserver", self.appId, "sharedKey")
     self.aud = self.systemConfig.getString(None, "authserver", self.appId, "aud")
     self.iss = self.systemConfig.getString(None, "authserver", self.appId, "iss")
     self.expiry = self.systemConfig.getInteger(None, "authserver", self.appId, "expiry")
     self.logoutUrl = self.systemConfig.getString(None, "authserver", self.appId, "logoutUrl")
     logout = self.request.getParameter("logout")
     if logout == "1":
         self.session.invalidate()
         self.response.sendRedirect(self.logoutUrl)
         return
     if not self.consumerName:
         self.msg = "Invalid configuration, no app name"
         self.log.error(self.msg)
         return
     if not self.sharedKey:
         self.msg = "Invalid shared Key"
         self.log.error(self.msg)
         return
     if not self.aud:
         self.msg = "Invalid aud"
         self.log.error(self.msg)
         return
     if not self.iss:
         self.msg = "Invalid iss"
         self.log.error(self.msg)
         return
     if not self.expiry:
         self.msg = "Invalid expiry"
         self.log.error(self.msg)
         return
                         
     # Because we don't trust the configuration
     current_user = self.vc("page").authentication.get_username()
     isAdmin = self.vc("page").authentication.is_admin()
     # Admin only... 
     if not isAdmin:
         self.msg = "Sorry, this page is only for administrators."
         self.log.error(self.msg)
         return
     # Get the roles...
     typ = "[\"" + "\",\"".join(self.vc("page").authentication.get_roles_list()) + "\"]"
     # Generating signature...
     dtNow = Date().getTime()
     now = dtNow / 1000
     iat = now
     nbf = now - 1
     exp = now + self.expiry
     secRandom = SecureRandom()
     jti = Long.toString(dtNow) + "_" + Integer.toString(secRandom.nextInt())
     payload = Payload('{"iss":"%s",  "sub":"%s", "aud":"%s", "iat":"%s", "nbf":"%s", "exp":"%s", "jti":"%s", "typ":%s}' % (self.iss, current_user, self.aud, iat, nbf, exp, jti, typ))
     jwsHeader = JWSHeader(JWSAlgorithm.HS256)
     macSigner = MACSigner(self.sharedKey)
     jwsObject = JWSObject(jwsHeader, payload)
     jwsObject.sign(macSigner)
     self.jws = jwsObject.serialize()
    print "Before optimization (%s) ... " % addTime.addString()
    tc.optimize( optimizationOptions['error'], optimizationOptions['maxIterations'], optimizationOptions['maxPlateau'] )
    print "After optimization (%s) ... " %addTime.addString()


# print "Write transformed images to file (%s) ... " % addTime.addString()
print "Saving files into directory %s (%s) ... " % (itsFolder, addTime.addString())

for layer, ts in tiles.iteritems():
    for patch, tileList in ts.iteritems():
        width  = shape[0]
        height = shape[1]
        stepX  = 1
        stepY  = 1

        filePath = itsFolder + display.project.getLoader().createIdPath(Long.toString(patch.getId()),
        								'it',
                                                                        '.tif')
        File(filePath).getParentFile().mkdirs()
        resultStack = ImageStack( width, height, 2 )
        parameter1p = FloatProcessor( width, height )
        parameter2p = FloatProcessor( width, height )
        resultStack.setProcessor( parameter1p, 1 )
        resultStack.setProcessor( parameter2p, 2 )
        resultImage = ImagePlus("", resultStack)
        for idx, t in sorted( tileList.iteritems(), key=lambda x : x[0] ):
            model = zeros( 2, 'd' )
            t.getModel().toArray( model )
            x, y = subscriptToIndex[idx - 1]
            parameter1p.setf(x, y, inverseMapTransforms[layer][patch].getNewLinearTerm(model[0]))
            parameter2p.setf(x, y, inverseMapTransforms[layer][patch].getNewConstantTerm(model[0], model[1]))