コード例 #1
0
    def _build_request_url(self, params):
        """
        Reference: http://docs.amazonwebservices.com/AmazonDevPay/latest/DevPayDeveloperGuide/index.html?LSAPI_Auth_REST.html
        """

        # Make a copy because we will modify the result:
        params = dict(params)
        if self._creds is not None:
            update_by_keywords_without_overwrite(
                params,
                AWSAccessKeyId=self._creds.access_key,
                SignatureVersion='1',
                Expires=timestamp.format_iso_time(time.time() + 15 * 60),
            )
        update_by_keywords_without_overwrite(
            params,
            Version='2008-04-28',
        )

        items = params.items()

        if self._creds is not None:
            signature = self._calc_signature(items)
            items.append(('Signature', signature))

        querystr = '&'.join(
            ['%s=%s' % (k, urllib.quote(v)) for (k, v) in items])

        return '%s?%s' % (self._endpoint.get_uri(), querystr)
コード例 #2
0
    def _build_request_url(self, params):
        """
        Reference: http://docs.amazonwebservices.com/AmazonDevPay/latest/DevPayDeveloperGuide/index.html?LSAPI_Auth_REST.html
        """

        # Make a copy because we will modify the result:
        params = dict(params)
        if self._creds is not None:
            update_by_keywords_without_overwrite(
                params,
                AWSAccessKeyId = self._creds.access_key,
                SignatureVersion = '1',
                Expires = timestamp.format_iso_time(time.time() + 15*60),
                )
        update_by_keywords_without_overwrite(
            params,
            Version = '2008-04-28',
            )

        items = params.items()

        if self._creds is not None:
            signature = self._calc_signature( items )
            items.append( ('Signature', signature) )

        querystr = '&'.join( ['%s=%s' % (k, urllib.quote(v)) for (k, v) in items] )

        return '%s?%s' % (self._endpoint.get_uri(), querystr)
コード例 #3
0
ファイル: servers.py プロジェクト: almet/leastauthority.com
def append_record(fp, *args):
    f = fp.open("a")
    try:
        f.write(",".join([
            format_iso_time(time.time()),
        ] + map(str, args)) + "\n")
    finally:
        f.close()
コード例 #4
0
def create_log_filepaths(stripe_plan_id, stripe_customer_id, stripe_subscription_id):
    logdir_parent_fp = FilePath('../').child('secrets').child(stripe_plan_id)
    timestamp = format_iso_time(time.time())
    fpcleantimestamp = timestamp.replace(':', '')
    logdirname = "%s-%s" % (fpcleantimestamp, get_bucket_name(stripe_customer_id, stripe_subscription_id)[len('lae-') :])
    abslogdir_fp = logdir_parent_fp.child(logdirname)
    abslogdir_fp.makedirs()
    stripelog_fp = abslogdir_fp.child('stripe')
    SSEC2log_fp = abslogdir_fp.child('SSEC2')
    signuplog_fp = abslogdir_fp.child('signup_logs')
    return abslogdir_fp, stripelog_fp, SSEC2log_fp, signuplog_fp
コード例 #5
0
    if len(sys.argv) < 5:
        print "Usage: python replace_server.py OLD_SECRETS_PATH AMI_IMAGE_ID INSTANCE_SIZE CUSTOMER_EMAIL"
        print "Happy replacement!"
        sys.exit(1)

    oldsecretspath = sys.argv[1]
    oldsecrets = simplejson.loads(FilePath(oldsecretspath).getContent())

    # TODO: ideally these would be in the secrets file.
    amiimageid = sys.argv[2]
    instancesize = sys.argv[3]
    customer_email = sys.argv[4]

    basefp = FilePath('..')
    seed = base64.b32encode(os.urandom(20)).rstrip('=').lower()
    logfilename = "%s-%s" % (format_iso_time(time.time()).replace(':', ''), seed)

    secretsfile = basefp.child('secrets').child(logfilename).open('a+')
    logfile = basefp.child('signup_logs').child(logfilename).open('a+')
    stdin = sys.stdin
    stdout = LoggingTeeStream(sys.stdout, logfile, '>')
    stderr = LoggingTeeStream(sys.stderr, logfile, '')

    # This is to work around the fact that fabric echoes all commands and output to sys.stdout.
    # It does have a way to disable that, but not (easily) to redirect it.
    sys.stdout = stderr

    def _close(res):
        stdout.flush()
        stderr.flush()
        secretsfile.close()
コード例 #6
0
    print >>stderr, "Received all fields, thanks."
    try:
        from lae_automation.signup import signup
        return signup(activationkey, productcode, name, email, keyinfo, stdout, stderr, seed, secretsfile, logfilename)
    except Exception:
        import traceback
        traceback.print_exc(100, stdout)
        raise

if __name__ == '__main__':
    try:
        defer.setDebugging(True)
        basefp = FilePath('..')
        seed = base64.b32encode(os.urandom(20)).rstrip('=').lower()
        logfilename = "%s-%s" % (format_iso_time(time.time()).replace(':', ''), seed)

        secretsfile = basefp.child('secrets').child(logfilename).open('a+')
        logfile = basefp.child('signup_logs').child(logfilename).open('a+')
        stdin = sys.stdin
        stdout = LoggingTeeStream(sys.stdout, logfile, '>')
        stderr = LoggingTeeStream(sys.stderr, logfile, '')

        # This is to work around the fact that fabric echoes all commands and output to sys.stdout.
        # It does have a way to disable that, but not (easily) to redirect it.
        sys.stdout = stderr

        def _close(res):
            stdout.flush()
            stderr.flush()
            secretsfile.close()
コード例 #7
0
 def test_format_iso_time(self):
     t = timestamp.format_iso_time(self.SOME_TIME)
     self.failUnlessEqual(t, self.SOME_TIMESTAMP)
コード例 #8
0
def append_record(fp, *args):
    f = fp.open("a")
    try:
        f.write(",".join([format_iso_time(time.time()),] + map(str, args)) + "\n")
    finally:
        f.close()
コード例 #9
0
 def test_format_iso_time(self):
     t = timestamp.format_iso_time(self.SOME_TIME)
     self.failUnlessEqual(t, self.SOME_TIMESTAMP)