#!/usr/bin/env python #coding=utf-8 import sys, os from aliyunsdkcore.client import AcsClient from aliyunsdkcore.request import CommonRequest from common import Common from time import gmtime, strftime import oss2 accessKeyId, accessKeySecret, endpoint, region, appid, ossbucketname, ossendpoint, securityToken = Common.LoadConfig( ) client = AcsClient(accessKeyId, accessKeySecret, region) def upload_war(warfilepath): auth = oss2.Auth(accessKeyId, accessKeySecret) bucket = oss2.Bucket(auth, ossendpoint, ossbucketname) oss2.resumable_upload(bucket, os.path.basename(warfilepath), warfilepath) warurl = "https://" + ossbucketname + "." + ossendpoint + "/" + os.path.basename( warfilepath) return warurl def deploy(warurl): request = CommonRequest() request.set_accept_format('json') request.set_method('POST')
import os, sys, time from app import app from flask import render_template, flash, redirect, request import oss2 from aliyun.log.logclient import LogClient sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + "/..") from common import Common from log import Log #Load config values accessKeyId, accessKeySecret, logEndPoint, logProject, logStore, ossEndPoint, ossBucketName, securityToken = Common.LoadConfig( ) #Initialise OSS authentication auth = oss2.Auth(accessKeyId, accessKeySecret) # Initialise Log Service authentication client client = LogClient(logProject + '.' + logEndPoint, accessKeyId, accessKeySecret) #Instantiate OSS bucket bucket = oss2.Bucket(auth, ossEndPoint, ossBucketName) @app.route('/') @app.route('/index') def index(): return render_template('base.html')