1
0
Fork 0

update .gitignore to ignore the folder .idea

Lanhui-add-articles
Hui Lan 2021-07-13 11:19:35 +08:00
commit d431c0cb4b
12 changed files with 122 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.idea/
venv/ venv/
app/__init__.py app/__init__.py
app/__pycache__/ app/__pycache__/

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

12
.idea/englishpal.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

7
.idea/misc.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/englishpal.iml" filepath="$PROJECT_DIR$/.idea/englishpal.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,3 +1,2 @@
FROM tiangolo/uwsgi-nginx-flask:python3.6 FROM tiangolo/uwsgi-nginx-flask:python3.6
COPY ./app /app COPY ./app /app

2
Jenkinsfile vendored
View File

@ -12,7 +12,7 @@ pipeline {
steps { steps {
echo 'Building..' echo 'Building..'
sh 'sudo docker build -t englishpal .' sh 'sudo docker build -t englishpal .'
sh 'sudo docker stop $(sudo docker ps -aq)' sh 'sudo docker stop $(docker ps -aq)'
sh 'sudo docker run -d -p 91:80 -v /var/lib/jenkins/workspace/EnglishPal_Pipeline_master/app/static/frequency:/app/static/frequency -t englishpal' sh 'sudo docker run -d -p 91:80 -v /var/lib/jenkins/workspace/EnglishPal_Pipeline_master/app/static/frequency:/app/static/frequency -t englishpal'
} }
} }

View File

@ -282,6 +282,12 @@ def familiar(username,word):
pickle_idea.familiar(user_freq_record,word) pickle_idea.familiar(user_freq_record,word)
return redirect(url_for('userpage', username=username)) return redirect(url_for('userpage', username=username))
@app.route("/<username>/<word>/del", methods=['GET', 'POST'])
def deleteword(username,word):
user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
pickle_idea2.deleteRecord(user_freq_record,word)
return redirect(url_for('userpage', username=username))
@app.route("/<username>", methods=['GET', 'POST']) @app.route("/<username>", methods=['GET', 'POST'])
def userpage(username): def userpage(username):
@ -356,9 +362,9 @@ def userpage(username):
freq = x[1] freq = x[1]
if isinstance(d[word], list): # d[word] is a list of dates if isinstance(d[word], list): # d[word] is a list of dates
if freq > 1: if freq > 1:
page += '<p class="new-word"> <a href="%s">%s</a>(<a title="%s">%d</a>) <a href="%s/%s/familiar">熟悉</a> <a href="%s/%s/unfamiliar">不熟悉</a> </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word) page += '<p class="new-word"> <a href="%s">%s</a>(<a title="%s">%d</a>) <a href="%s/%s/familiar">熟悉</a> <a href="%s/%s/unfamiliar">不熟悉</a> <a href="%s/%s/del">删除</a> </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word)
else: else:
page += '<p class="new-word"> <a href="%s">%s</a>(<a title="%s">%d</a>) <a href="%s/%s/familiar">熟悉</a> <a href="%s/%s/unfamiliar">不熟悉</a> </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word) page += '<p class="new-word"> <a href="%s">%s</a>(<a title="%s">%d</a>) <a href="%s/%s/familiar">熟悉</a> <a href="%s/%s/unfamiliar">不熟悉</a> <a href="%s/%s/del" >删除</a> </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word)
elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format. elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format.
page += '<a href="%s">%s</a>%d\n' % (youdao_link(word), word, freq) page += '<a href="%s">%s</a>%d\n' % (youdao_link(word), word, freq)
return page return page

View File

@ -25,6 +25,15 @@ def lst2dict(lst, d):
else: else:
d[word] += dates d[word] += dates
def deleteRecord(path,word):
with open(path, 'rb') as f:
db = pickle.load(f)
try:
db.pop(word)
except KeyError:
print("sorry")
with open(path, 'wb') as ff:
pickle.dump(db, ff)
def dict2lst(d): def dict2lst(d):
if len(d) > 0: if len(d) > 0:

View File

@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
# Run the docker image using the following command:
# docker run -d -p 4444:4444 selenium/standalone-chrome
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import random, time
import string
# 调用本地chromedriver
# driver = webdriver.Chrome(executable_path="D:\ChromeDriver\chromedriver.exe")
# driver.get("http://127.0.0.1:5000/")
driver = webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.CHROME)
driver.implicitly_wait(10)
# driver.maximize_window()
# HOME_PAGE = "http://127.0.0.1:5000/"
HOME_PAGE = 'http://121.4.94.30:91/'
def test_delete_word():
try:
driver.get(HOME_PAGE)
assert 'English Pal -' in driver.page_source
# login
elem = driver.find_element_by_link_text('登录')
elem.click()
uname = 'lanhui'
password = 'l0ve1t'
elem = driver.find_element_by_name('username')
elem.send_keys(uname)
elem = driver.find_element_by_name('password')
elem.send_keys(password)
elem = driver.find_element_by_xpath('//form[1]/p[3]/input[1]') # 找到登录按钮
elem.click()
assert 'EnglishPal Study Room for ' + uname in driver.title
# delete
elems = driver.find_element_by_class_name('new-word')
# 移动到元素elems对象的“顶端”与当前窗口的“顶部”对齐
driver.execute_script("arguments[0].scrollIntoView();", elems)
driver.save_screenshot('test_delete_pic1.png')
current_2 = elems.text
elem = driver.find_element_by_link_text("删除")
elem.click()
elems = driver.find_element_by_class_name('new-word')
driver.execute_script("arguments[0].scrollIntoView();", elems)
driver.save_screenshot('test_delete_pic2.png')
now_2 = elems.text
assert current_2 != now_2
finally:
driver.quit()
# test_delete_word()