Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
2a71e5a0
Commit
2a71e5a0
authored
Sep 11, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自动生成协议
parent
ecd14d42
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
0 deletions
+124
-0
script/privacy/__pycache__/api.cpython-36.pyc
+0
-0
script/privacy/api.py
+85
-0
script/privacy/api.pyc
+0
-0
script/privacy/update_privacy.py
+34
-0
script/script_help.sh
+5
-0
No files found.
script/privacy/__pycache__/api.cpython-36.pyc
0 → 100644
View file @
2a71e5a0
File added
script/privacy/api.py
0 → 100644
View file @
2a71e5a0
# -*-coding:utf-8-*-
import
requests
import
io
import
json
import
string
class
Api
:
host
=
"https://biz.apollo.starblingbling.com"
mobile
=
"18512342222"
pwd
=
"android"
token
=
""
# def loadConfig(self):
# with io.open('config.json', "r+") as fin:
# return json.load(fin)
# def updateConfig(self,config):
# with io.open("config.json", "w+") as fout:
# fout.write(json.dumps(config, ensure_ascii=False))
def
getToken
(
self
):
return
self
.
token
# with io.open('config.json', "r+") as fin:
# return json.load(fin)['token']
# 登录
def
login
(
self
,
account
,
pwd
):
url
=
self
.
host
+
"/api/api/login"
params
=
{
'mobile'
:
account
,
'password'
:
pwd
}
result
=
requests
.
post
(
url
,
params
)
if
result
.
status_code
==
200
:
self
.
token
=
result
.
json
()[
'data'
][
'token'
]
# config = self.loadConfig()
# config['token'] = token
# self.updateConfig(config)
# print("token已更新")
else
:
print
(
result
.
json
())
def
handleResult
(
self
,
result
):
if
result
.
json
()[
'code'
]
!=
"OK"
:
print
(
"api error: "
,
result
.
url
)
print
(
result
.
json
())
if
"token invalid"
in
result
.
json
()[
'message'
]:
print
(
"token失效,正在重新登录,稍后再试..."
)
self
.
login
(
self
.
mobile
,
self
.
pwd
)
else
:
return
True
return
False
# 生成新的协议
def
new_privacy
(
self
,
crop_id
,
app_name
,
oss_path
):
self
.
login
(
self
.
mobile
,
self
.
pwd
)
url
=
self
.
host
+
"/api/api/privacies"
params
=
{
'corpId'
:
crop_id
,
'corpName'
:
app_name
,
'packageName'
:
oss_path
}
header
=
{
'X-AUTH-TOKEN'
:
self
.
getToken
()}
result
=
requests
.
post
(
url
,
json
=
params
,
headers
=
header
)
if
(
"corpId"
in
result
.
text
and
"packageName"
in
result
.
text
and
"exists"
in
result
.
text
):
print
(
"文件已存在,正在转到更新接口..."
)
success
=
self
.
update_privacy
(
crop_id
,
app_name
,
oss_path
)
if
not
success
and
result
.
json
()[
'code'
]
!=
"OK"
:
return
False
if
self
.
upload_privacy
(
crop_id
,
oss_path
):
print
(
"更新协议成功!"
)
return
True
return
False
#更新协议
def
update_privacy
(
self
,
crop_id
,
app_name
,
oss_path
):
url
=
self
.
host
+
"/api/api/privacies/regenerate/
%
s/
%
s"
%
(
crop_id
,
oss_path
)
params
=
{
'corpId'
:
crop_id
,
'corpName'
:
app_name
,
'packageName'
:
oss_path
}
header
=
{
'X-AUTH-TOKEN'
:
self
.
getToken
()}
result
=
requests
.
put
(
url
,
json
=
params
,
headers
=
header
)
return
self
.
handleResult
(
result
)
#上传协议
def
upload_privacy
(
self
,
crop_id
,
oss_path
):
url
=
self
.
host
+
"/api/api/privacies/upload-to-oss/
%
s/
%
s"
%
(
crop_id
,
oss_path
)
params
=
{
'corpId'
:
crop_id
,
'packageName'
:
oss_path
}
header
=
{
'X-AUTH-TOKEN'
:
self
.
getToken
()}
result
=
requests
.
put
(
url
,
json
=
params
,
headers
=
header
)
return
self
.
handleResult
(
result
)
script/privacy/api.pyc
0 → 100644
View file @
2a71e5a0
File added
script/privacy/update_privacy.py
0 → 100644
View file @
2a71e5a0
# -*-coding:utf-8-*-
from
api
import
Api
import
sys
import
requests
import
io
import
os
import
json
crop_id
=
sys
.
argv
[
1
]
app_name
=
sys
.
argv
[
2
]
privacy_url
=
sys
.
argv
[
3
]
update_local
=
sys
.
argv
[
4
]
error_url
=
privacy_url
.
replace
(
"privacy.html"
,
"privacy_error.html"
)
oss_path
=
requests
.
get
(
error_url
)
.
text
\
.
split
(
"<Key>"
)[
1
]
\
.
split
(
"</Key>"
)[
0
]
\
.
split
(
"/"
)[
1
]
print
(
"crop_id:
%
s, app_name:
%
s, osspath:
%
s"
%
(
crop_id
,
app_name
,
oss_path
))
api
=
Api
()
success
=
api
.
new_privacy
(
str
(
crop_id
),
app_name
,
oss_path
)
#是否更新本地文件
path
=
"../../../app/src/main/assets/web/"
.
replace
(
"/"
,
os
.
path
.
sep
)
if
not
os
.
path
.
exists
(
path
):
os
.
makedirs
(
path
)
if
success
and
update_local
==
"true"
:
content
=
requests
.
get
(
privacy_url
)
.
text
with
io
.
open
(
path
+
"privacy.html"
,
"w+"
,
encoding
=
"ISO-8859-1"
)
as
fout
:
fout
.
write
(
content
)
print
(
"本地协议已更新!"
)
script/script_help.sh
View file @
2a71e5a0
...
...
@@ -28,6 +28,7 @@ echo "23、字符串加密"
echo
"24、添加toolbox库"
echo
"25、马甲包切换"
echo
"26、打印checklist"
echo
"27、更换隐私协议"
echo
" "
if
[[
"
$app_name
"
==
"
$majia_name
"
]]
;
then
...
...
@@ -280,6 +281,10 @@ elif (($commod == '26'));then
file_name
=
"
${
corp_id
}
_
${
app_name
}
"
mv /Users/connor/Documents/apks/
"
${
file_name
}
.apk"
/Users/connor/Documents/apks/
"
${
file_name
}
/app.apk"
elif
((
$commod
==
'27'
))
;
then
cd
privacy
python update_privacy.py
"
${
corp_id
}
"
"
${
app_name
}
"
"
${
agreement_url
}
"
"true"
elif
((
$commod
==
'10000'
))
then
cd
..
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment