Pārlūkot izejas kodu

删除多余文件

chenjunkai 7 gadi atpakaļ
vecāks
revīzija
8a792aa222

+ 0 - 10
Ansjer/test/666.py

@@ -1,10 +0,0 @@
-from Crypto.PublicKey import RSA
-code = 'noonekowns'
-key = RSA.generate(2048)
-encrypted_key =key.exportKey(passphrase=code, pkcs=8,protection="scryptAndAES128-CBC")
-
-print(encrypted_key)
-exit()
-
-with open('/path_to_public_key/my_rsa_public.pem', 'wb') as f:
-    f.write(key.publickey().exportKey())

+ 0 - 151
Ansjer/test/SyncdbTools.sh

@@ -1,151 +0,0 @@
-#!/bin/bash
-### BEGIN INIT INFO
-# Provides:          Liuzhiting
-# Required-Start:    $local_fs $remote_fs $network $syslog
-# Required-Stop:     $local_fs $remote_fs $network $syslog
-# Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
-# Short-Description: starts the mysql migrate
-# Description:       A database migration script for a back-end server system.
-### END INIT INFO
-
-function mysqlDump(){
-        echo 你输入的文件名称是:$3.txt
-	echo $1 $2 $3 $4 $3.txt $(date +%Y%m%d)
-	filePath="/mnt/sql/$(date +%Y%m%d)/"
-	if [ ! -x "$filePath" ];then
-		mkdir -p "$filePath"
-	fi
-
-        if [ "$2" == "all" ];then
-                echo 你选择的是全部备份,正在备份迁移请等待...
-		mysqldump -u root -pliuzhiting $1 > $filePath$3.txt
-		
-		filesize=$(stat -c "%s" $filePath$3.txt)
-		
-		if [ $filesize -gt 0 ];then
-			fullPath=$filePath$3.txt
-			echo "$fullPath $filesize 1024" | awk '{printf("备份文件全路径是:%s,文件大小:%0.5fkb\n", $1, $2/$3)}'
-			echo 备份迁移完成...
-			return 0
-		else
-			echo 未知原因,无法备份迁移...
-			return -1
-		fi
-
-
-        elif [ "$2" == "table" ];then
-                echo 你选择的备份的表格是:$4
-		mysqldump -u root -pliuzhiting $1 $4 > $filePath$3.txt
-		
-		filesize=$(stat -c "%s" $filePath$3.txt)
-		
-		if [ $filesize -gt 0 ];then
-			# echo 备份文件全路径:$filePath$3.txt,文件大小:$[$filesize/1024]kb
-			fullPath=$filePath$3.txt
-			echo "$filesize 1024 $fullPath" | awk '{printf("备份文件全路径是:%s,文件大小:%0.5fkb\n", $3, $1/$2)}'
-			echo 备份迁移完成...
-			return 0
-		else
-			echo 未知原因,无法备份迁移...
-			return -1
-		fi
-
-	else
-		echo $2
-                echo $3
-        fi
-
-        return -1
-}
-
-function manageDumpData () {
-	echo $1 $2 $3 $4
-	filePath="/mnt/sql/$(date +%Y%m%d)/"
-	if [ ! -x "$filePath" ];then
-		echo 正在创建$filePath文件夹
-		mkdir -p "$filePath"
-		echo 创建完成...
-	fi
-
-	echo $filePath$3.json
-
-	if [ ! -x "$1" ];then
-		echo 项目文件路径不存在,"$1"...
-		return -1
-	fi
-
-	cd "$1"
-	if [ "$2" == "all" ];then
-		echo 你选择的是备份项目数据库全部表格
-		if [ ! -f "$1manage.py" ];then
-			echo 项目路径下不存在"$1manage.py"
-			return -1
-		fi
-
-		python3 manage.py dumpdata > $filePath$3.json
-		
-		filesize=$(stat -c "%s" $filePath$3.json)
-
-		if [ $filesize -gt 0 ];then
-			fullPath=$filePath$3.json
-			echo "$fullPath $filesize 1024" | awk '{printf("备份文件全路径是:%1,文件大小:%0.5fkb\n", $1, $2/$3}'
-			echo 备份迁移完成...
-			return 0
-		else
-			echo 未知原因,无法备份迁移...
-			return -1
-		fi
-
-	elif [ "$2" == "app" ];then
-		echo 你选择备份Appname名称是:$4
-		python3 manage.py dumpdata $4 > $filePath$3.json
-		
-		filesize=$(stat -c "%s" $filePath$3.json)
-
-		if [ $filePath -gt 0 ];then
-			fullPath=$filePath$3.json
-			echo "$fullPath $filesize 1024" | awk '{printf("备份文件全路径是:%1,文件大小:%0.5fkb\n", $1, $2/$3}'
-			echo 备份迁移完成...
-			return 0
-		else
-			echo 未知原因,无法备份迁移...
-			return -1
-		fi
-	else
-		echo "YYYYY"
-
-		return 0
-	fi
-
-	return -1	
-
-}
-
-
-read -t 30 -p "请输入迁移方式(mysql自带方式[dump]或者Python方式[migrate],如果你选择的是mysql方式请再输入要备份的数据库名称[请按空格隔开,30秒完成输入]):" migrate dbname
-echo "$migrate" $dbname
-if [ ! $migrate ];then
-	migrate="dump"
-	dbname='Ansjer'
-fi
-
-if [ "$migrate" == "dump" ];then
-    echo 你选择的是MySQL备份方式,并且你要备份的数据库是:$dbname
-    read -t 30 -p "请先输入文件名称,然后选择备份所有数据[all] 或者备份其中一个表格[table],如果选择的备份其中一个表格请再输入表格名称[每个输入用表格隔开]" filename database tablename
-    echo ddde, $database $filename $tablename
-    filename=${filename:-dump} #当变量a为null或为空字符串时则var=b var=${a:-b}
-    database=${database:-all}
-    mysqlDump $dbname $database $filename $tablename
-    echo $?
-elif [ "$migrate" == "migrate" ];then
-    echo 你选择的是Python方式备份迁移数据库...
-    projPath="/mnt/Sharing/Ansjer/"
-    read -t 30 -p "(请先输入要备份的文件名称,然后是选择要备份appname或者备份全部,如果全部清输入[all],或者输入[app]再输入appnname):" filename database appname
-    filename=${filename:-dump}
-    database=${database:-all}
-    manageDumpData $projPath $database $filename $appname
-    echo $?
-else
-    echo ay
-fi

+ 0 - 71
Ansjer/test/encryDownLoad.py

@@ -1,71 +0,0 @@
-# coding=utf-8
-# + + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + +
-#        ┏┓   ┏┓+ +
-#    ┏┛┻━━━┛┻┓ + +
-#    ┃       ┃  
-#    ┃   ━   ┃ ++ + + +
-#    ████━████ ┃+
-#    ┃       ┃ +
-#    ┃   ┻   ┃
-#    ┃       ┃ + +
-#    ┗━┓   ┏━┛
-#      ┃   ┃           
-#      ┃   ┃ + + + +
-#      ┃   ┃    Codes are far away from bugs with the animal protecting   
-#      ┃   ┃ +     神兽保佑,代码无bug  
-#      ┃   ┃
-#      ┃   ┃  +         
-#      ┃    ┗━━━┓ + +
-#      ┃        ┣┓
-#      ┃        ┏┛
-#      ┗┓┓┏━┳┓┏┛ + + + +
-#       ┃┫┫ ┃┫┫
-#       ┗┻┛ ┗┻┛+ + + +
-# + + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + ++ + + +"""
-"""
-"""
-import base64
-import hashlib
-import time
-
-def md5(text, isBackByte=False):
-    """md5加密函数"""
-    md5 = hashlib.md5()
-    if isinstance(text, bytes):
-        md5.update(text)
-    else:
-        md5.update(text.encode('utf-8'))
-
-    if isBackByte:
-        # 返回二进制的加密结果
-        return md5.digest()
-
-        # 返回十六进制的机密结果
-    return md5.hexdigest()
-
-
-def base64_encode(text, isBytes=False):
-    """进行base64编码处理"""
-    if isBytes:
-        return base64.b64encode(text)
-    return base64.b64encode(bytes(text, encoding="utf-8"))
-
-
-def get_timestamp10():
-    """获取当前时间长度为10位长度的时间戳"""
-    return int(time.time())
-
-
-secret = 'ansjer';  # 密钥--对应#st的哈希格式为 secret+url+e,e为时间戳单位s,url为请求地址  secure_link_md5 xiaozhong.com$uri$arg_e;
-# path = '/hls/5553.mp4/index.m3u8'  # 下载文件
-# path = '/L59KVYDAEPHR1T6M111A_0/555666.mp4'  # 下载文件
-path = '/5553.mp4'  # 下载文件
-# path = '/444.mp4'  # 下载文件
-# 下载到期时间,time是当前时间,300表示300秒,也就是说从现在到300秒之内文件不过期
-expire = get_timestamp10() + 3600;
-res = md5(str(secret) + str(path) + str(expire), True)
-md5 = str(base64_encode(res, True))
-md5 = md5.replace('b\'', '').replace('\'', '').replace('+', '-').replace('/', '_').replace('=', '')
-
-# print('生成代相关认证签名的地址:','http://52.8.197.107/444.mp4.m3u8?' + 'st=' + str(md5) + '&e=' + str(expire))
-print('io:','http://52.8.197.107/5553.mp4.m3u8?' + 'st=' + str(md5) + '&e=' + str(expire))

+ 0 - 24
Ansjer/test/m3u8_generate.py

@@ -1,24 +0,0 @@
-#!/usr/bin/env python3  
-# -*- coding: utf-8 -*-  
-"""
-@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
-@AUTHOR: ASJRD018
-@NAME: Ansjer
-@software: PyCharm
-@DATE: 2018/5/28 16:15
-@Version: python3.6
-@MODIFY DECORD:ansjer dev
-@file: m3u8_generate.py
-@Contact: chanjunkai@163.com
-"""
-from m3u8_generator import PlaylistGenerator
-#pip install m3u8-generator
-playlist_entries = [
-    {
-        'name': "http://d3596w5a6euckc.cloudfront.net/vod/2N1K3LE78TYJ38CE111A_99/1234.ts?Expires=1538265600&Signature=czbcIzioBcb3K7F8v5QvKNRJ9af9022O3e9ils4bTsA2O4LSR6UxF1uLCvykHsVrdLZiYt3f5dW1Njb2qWJu1nB6N9lPUIfJTNEuD9Z3SyxEboM0Cvb34MWpFe94vdWIIas1x0bdwTGWb-yX34XJgxSMhkO9ZA5Avzvl3OALoWcoIdyvniXA5x9bgcmFu5aXXN1Fy1u4lPYQgDUGHOc-hiyZP7yY2btl0dViEjEX76n9eS067nAwAGM4zV0Ga4surZ99tyfOIsjLjRieNOzMMfYLnMXxndFRXgYUF~uVIsxOfJ5Q4QkJBakfx2Vxv4y5ZfX09ajtkGu0qfybWPs0xA__&Key-Pair-Id=APKAINI6BNPKV54NHH7Q",
-        'duration': '2',
-    }
-]
-
-playlist = PlaylistGenerator(playlist_entries).generate()
-print(playlist)

+ 0 - 113
Ansjer/test/signCookie.py

@@ -1,113 +0,0 @@
-from boto.cloudfront.distribution import Distribution
-from cryptography.hazmat.primitives.asymmetric import padding
-from cryptography.hazmat.primitives import serialization
-from cryptography.hazmat.backends import default_backend
-from cryptography.hazmat.primitives import hashes
-import base64
-import datetime
-from var_dump import var_dump
-import time
-
-
-class BetterThanBoto(Distribution):
-
-    def sign_rsa(self, message):
-        private_key = serialization.load_pem_private_key(self.keyfile, password=None,
-                                                         backend=default_backend())
-        signer = private_key.signer(padding.PKCS1v15(), hashes.SHA1())
-        message = message.encode('utf-8')
-        signer.update(message)
-        return signer.finalize()
-
-    def _sign_string(self, message, private_key_file=None, private_key_string=None):
-        if private_key_file:
-            self.keyfile = open(private_key_file, 'rb').read()
-        elif private_key_string:
-            self.keyfile = private_key_string.encode('utf-8')
-        return self.sign_rsa(message)
-
-    @staticmethod
-    def _url_base64_encode(msg):
-        """
-        Base64 encodes a string using the URL-safe characters specified by
-        Amazon.
-        """
-        msg_base64 = base64.b64encode(msg).decode('utf-8')
-        msg_base64 = msg_base64.replace('+', '-')
-        msg_base64 = msg_base64.replace('=', '_')
-        msg_base64 = msg_base64.replace('/', '~')
-        return msg_base64
-
-    def generate_signature(self, policy, private_key_file=None):
-        """
-        :param policy: no-whitespace json str (NOT encoded yet)
-        :param private_key_file: your .pem file with which to sign the policy
-        :return: encoded signature for use in cookie
-        """
-        # Distribution._create_signing_params()
-        signature = self._sign_string(policy, private_key_file)
-
-        # now base64 encode the signature & make URL safe
-        encoded_signature = self._url_base64_encode(signature)
-
-        return encoded_signature
-
-    def create_signed_cookies(self, url, private_key_file=None, keypair_id=None,
-                              expires_at=20, secure=True):
-        policy = self._custom_policy(
-            url,
-            expires_at
-        )
-
-        encoded_policy = self._url_base64_encode(policy.encode('utf-8'))
-        signature = self.generate_signature(
-            policy, private_key_file=private_key_file
-        )
-        cookies = {
-            "CloudFront-Policy": encoded_policy,
-            "CloudFront-Signature": signature,
-            "CloudFront-Key-Pair-Id": keypair_id
-        }
-        return cookies
-
-
-def sign_to_cloudfront(object_url, expires_at):
-    """ Sign URL to distribute file"""
-    cf = BetterThanBoto()
-    url = cf.create_signed_url(url=object_url,
-                               keypair_id="APKAINI6BNPKV54NHH7Q",
-                               expire_time=expires_at,
-                               private_key_file="D:/project_svn/Ansjer/test/pk-APKAINI6BNPKV54NHH7Q.pem")
-
-    return url
-
-
-def create_signed_cookies(object_url, expires_at):
-    """
-    Create a signed cookie
-    """
-    cf = BetterThanBoto()
-
-    cookies = cf.create_signed_cookies(url=object_url, keypair_id="APKAINI6BNPKV54NHH7Q", expires_at=expires_at,
-                                       private_key_file="D:/project_svn/Ansjer/test/pk-APKAINI6BNPKV54NHH7Q.pem")
-    return cookies
-
-
-expire_date = int(time.time()) + 7200
-
-object_url = 'http://d3596w5a6euckc.cloudfront.net/vod/2N1K3LE78TYJ38CE111A_99/1527152855.m3u8'
-# object_url = 'http://d3596w5a6euckc.cloudfront.net/vod/2N1K3LE78TYJ38CE111A_99/*'
-# cookie_data = create_signed_cookies(object_url, expire_date)
-# print(cookie_data)
-# exit()
-cookie_data = {'CloudFront-Policy': 'eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cDovL2QzNTk2dzVhNmV1Y2tjLmNsb3VkZnJvbnQubmV0L3ZvZC8yTjFLM0xFNzhUWUozOENFMTExQV85OS8qIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNTI3NTA1MDA1fX19XX0_', 'CloudFront-Signature': 'IQYo7PdwXLRyEywSon6HBvuaEOLqTGH6qWAx1Fk3HrSK6N325f0oXcvpZ1eSVUv353YUrd6bKPDE9tLEOPuIitILNQt5tP593C5OIX4jc15RpUpTuEQdlVlO7~SfnxtHXIqukD20GXWIfCagneNj1~F2OD5Tn8ER2stJY1IK~v12VPXAA-cWqoKc6WyVZfzJs0SkJIfQDeDtSOkKD0fP8TOBM2i4XQzbcl9NviNrueG-bZwrCondlw6K5g4TOVS41QQplEIOwb1AzxBb8QvDXxaQ-Kcmy5ME-vpfdBqdHrgreAGZIliZyLWA3qIJ71w67YIzsnCvCMytULDE7w-d4Q__', 'CloudFront-Key-Pair-Id': 'APKAINI6BNPKV54NHH7Q'}
-
-print(cookie_data)
-import requests
-
-cookies = cookie_data
-headers = {}
-# exit()
-s = requests.Session()
-res = s.get(object_url, headers=headers, cookies=cookies)
-print(res.text)

+ 0 - 140
Ansjer/test/testa.py

@@ -1,140 +0,0 @@
-
-
-
-
-
-
-
-# -*- coding: utf-8 -*-
-import struct
-import boto3
-from boto3.session import Session
-from datetime import datetime
-import time
-from requests_aws4auth import AWS4Auth
-import requests
-import chunk
-from botocore.client import Config
-print(datetime(2015, 1, 1))
-print(time.time())
-# exit()
-aws_key = 'AKIAJYSIOA24FQANOFTA'
-aws_secret = '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'
-# aws_key = 'AKIAIK7LP7TRWPFTRWVA'
-# aws_secret = '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'
-session = Session(
-    aws_access_key_id=aws_key,
-    aws_secret_access_key=aws_secret,
-    region_name='us-east-1',
-)
-
-'''
-s3
-'''
-s3_con = boto3.client(
-    's3', aws_access_key_id=aws_key, aws_secret_access_key=aws_secret,
-    config=Config(signature_version='s3v4'), region_name='us-east-1'
-)
-url = s3_con.generate_presigned_post(
-    Key='img.jpg',
-    ExpiresIn=7200,
-    Bucket='ansjertest'
-)
-print(url)
-exit()
-url = s3_con.generate_presigned_url(
-    'put_object',
-    Params={
-        'Bucket': 'ansjertest',
-        'Key': 'img.jpg',
-        # 'ContentType': 'image/jpg'
-    },
-    ExpiresIn=3600,
-    HttpMethod='PUT'
-)
-print(url)
-exit()
-S3_client = session.client('s3')
-response = S3_client.generate_presigned_url(
-    'put_object',
-    Params={
-        'Bucket': 'ansjertest',
-        'Key': 'img.jpg',
-        # 'ContentType': 'image/jpg'
-    },
-    ExpiresIn=3600,
-    # HttpMethod='PUT'
-)
-print(response)
-
-exit()
-S3_client = session.client('s3')
-response = S3_client.generate_presigned_url(
-    'get_object',
-    Params={
-        'Bucket': 'ansjertest',
-        'Key': '2N1K3LE78TYJ38CE111A_3/2N1K3LE78TYJ38CE111A_3-1524557834.mp4'
-    },
-    ExpiresIn=3600
-)
-print(response)
-exit()
-
-kinesis_client = session.client('kinesisvideo')
-
-response = kinesis_client.get_data_endpoint(
-    StreamName='demo-stream',
-    APIName='GET_MEDIA_FOR_FRAGMENT_LIST'
-)
-endpoint = response['DataEndpoint'] + '/getMediaForFragmentList'
-print(endpoint)
-data = {
-    "Fragments": ["91343852333181432407537343081996969589651220552"],
-    "StreamName": "demo-stream"
-}
-
-auth = AWS4Auth(aws_key, aws_secret, 'us-east-1', 'kinesisvideo')
-headers = {'Content-type': 'application/json'}
-response = requests.post(endpoint, json=data, auth=auth, headers=headers)
-# test=chunk.Chunk(response.text.encode('utf8'))
-print(response.headers)
-exit()
-
-stream_bytes = response.text.encode('utf8')
-print(response.text.encode('utf8'))
-print('3333')
-exit()
-# url = "网络zip的地址"
-# path = "你本地的地址"
-#
-# req = urllib2.urlopen(url)
-# data = req.read()
-# with open(path, "wb") as zip:
-#     zip.write(data)
-# req.close()
-# ##-----------------------------------------------------------------------------------------
-
-
-exit()
-response_describe_stream = kinesis_client.describe_stream(
-    StreamName='demo-stream',
-)
-print(response_describe_stream)
-# exit()
-response = kinesis_client.get_data_endpoint(
-    StreamName='demo-stream',
-    APIName='GET_MEDIA'
-)
-print(response)
-
-# exit()
-print('-----------')
-print(response['DataEndpoint'])
-
-kinesis_video_media_client = session.client('kinesis-video-media')
-response_media = kinesis_video_media_client.get_media(
-    StreamName='demo-stream',
-    StartSelector={
-        'StartSelectorType': 'EARLIEST ',
-    }
-)

+ 0 - 5
DB/data.json

@@ -1,5 +0,0 @@
-{
-  "code": "200",
-  "res": {},
-  "msg":{}
-}