From c2a0301b3775cd229538f617463254fe657c98d8 Mon Sep 17 00:00:00 2001 From: xianhu Date: Mon, 28 Oct 2019 17:50:16 +0800 Subject: [PATCH 01/15] update docker to 6.10.2 --- Docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 8ea6b8d..82d59ce 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,6 +1,6 @@ # Dockerfile by xianhu: build a docker image # centos6: -# docker build -t user/centos:v6.10.1 . +# docker build -t user/centos:v6.10.2 . # docker run -it --name test [-p -v] user/centos # docker attach test # centos7: From 7ab2e9ac6ffabe70dee5e1c025f5797fe0b8e4f2 Mon Sep 17 00:00:00 2001 From: xianhu Date: Mon, 28 Oct 2019 17:58:05 +0800 Subject: [PATCH 02/15] update docker --- Docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 82d59ce..4a20113 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,11 +1,11 @@ # Dockerfile by xianhu: build a docker image # centos6: # docker build -t user/centos:v6.10.2 . -# docker run -it --name test [-p -v] user/centos +# docker run -it --name test [-p -v] user/centos:v6.10.2 # docker attach test # centos7: # docker build -t user/centos:v7.0.1 . -# docker run -dt --privileged --name test [-p -v] user/centos +# docker run -dt --privileged --name test [-p -v] user/centos:v7.0.1 # docker exec -it test /bin/bash # FROM centos:7 From 7613b5fb8d7cd5162c15cbba59432d471f03d0c2 Mon Sep 17 00:00:00 2001 From: xianhu Date: Tue, 3 Dec 2019 16:17:23 +0800 Subject: [PATCH 03/15] update mail --- python_mail.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python_mail.py b/python_mail.py index 07dd267..a57049a 100644 --- a/python_mail.py +++ b/python_mail.py @@ -10,15 +10,17 @@ from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart -# 第三方 SMTP 服务(以腾讯企业邮件为例) +# 第三方 SMTP 服务(以腾讯企业邮件和QQ邮箱为例) mail_host = "smtp.exmail.qq.com" +# mail_host = "smtp.qq.com" mail_user = "from@from.com.cn" -mail_pass = "pwd" +# mail_user = "from@qq.com" +mail_pass = "授权码" mail_sender = mail_user +mail_port = 465 mail_receivers = ["to@to.com", "to@qq.com"] # 设置邮件格式、内容等 -- 普通格式 ================================================ -msg_plain = "邮件内容" message = MIMEText("邮件内容", "plain", "utf-8") # 设置邮件格式、内容等 -- HTML格式 =============================================== @@ -61,8 +63,7 @@ try: # 登录,并发送邮件 - smtpObj = smtplib.SMTP() - smtpObj.connect(mail_host, 25) + smtpObj = smtplib.SMTP_SSL(mail_host, mail_port) smtpObj.login(mail_user, mail_pass) smtpObj.sendmail(mail_sender, mail_receivers, message.as_string()) print("success") From efd71d85ee432b0f361b81beef5a5de0871318a5 Mon Sep 17 00:00:00 2001 From: xianhu Date: Thu, 30 Apr 2020 10:55:40 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E5=8D=87=E7=BA=A7docker=EF=BC=8C?= =?UTF-8?q?=E5=AE=89=E8=A3=85OpenCV=E5=92=8CPillow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docker/Dockerfile | 7 +++++-- Docker/requirements.txt | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 4a20113..c065937 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,7 +1,7 @@ # Dockerfile by xianhu: build a docker image # centos6: -# docker build -t user/centos:v6.10.2 . -# docker run -it --name test [-p -v] user/centos:v6.10.2 +# docker build -t user/centos:v6.10.3 . +# docker run -it --name test [-p -v] user/centos:v6.10.3 # docker attach test # centos7: # docker build -t user/centos:v7.0.1 . @@ -36,6 +36,9 @@ RUN yum install -y crontabs RUN yum install -y zlib-devel RUN yum install -y sqlite-devel RUN yum install -y openssl-devel +RUN yum install -y libSM.x86_64 +RUN yum install -y libXrender.x86_64 +RUN yum install -y libXext.x86_64 # install python RUN yum install -y https://centos6.iuscommunity.org/ius-release.rpm diff --git a/Docker/requirements.txt b/Docker/requirements.txt index 9333583..9e92142 100644 --- a/Docker/requirements.txt +++ b/Docker/requirements.txt @@ -1,17 +1,21 @@ -virtualenv pylint +virtualenv + lxml html5lib xmltodict pybloom_live fake-useragent beautifulsoup4 + aiohttp requests websocket-client + redis PyMySQL elasticsearch + Flask Flask-WTF Flask-Mail @@ -23,17 +27,23 @@ Flask-Migrate Flask-HTTPAuth Flask-Bootstrap Flask-SQLAlchemy + dash dash-table dash-core-components dash-html-components dash-bootstrap-components -gunicorn + uWSGI +gunicorn + numpy scipy pandas -scikit-learn -matplotlib plotly jupyter +matplotlib +scikit-learn + +Pillow +opencv-python From b983bc4562f010d577e36db6501f5fe031e6d4c0 Mon Sep 17 00:00:00 2001 From: qixianhu Date: Tue, 19 May 2020 17:44:53 +0800 Subject: [PATCH 05/15] update dockerfile --- .gitignore | 1 + Docker/Dockerfile | 44 +++++++++++++++++++------------------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 9be43b8..ab59a67 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ *.csv .* +venv/ test/ data/ build/ diff --git a/Docker/Dockerfile b/Docker/Dockerfile index c065937..0b7c66b 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,20 +1,13 @@ # Dockerfile by xianhu: build a docker image -# centos6: -# docker build -t user/centos:v6.10.3 . -# docker run -it --name test [-p -v] user/centos:v6.10.3 -# docker attach test -# centos7: -# docker build -t user/centos:v7.0.1 . -# docker run -dt --privileged --name test [-p -v] user/centos:v7.0.1 -# docker exec -it test /bin/bash +# docker build -t user/centos:v7.8.1 . +# docker run -it --name test [-p -v] user/centos:v7.8.1 -# FROM centos:7 -FROM centos:6.10 +FROM centos:7.8.2003 MAINTAINER xianhu # change system environments -ENV LANG en_US.UTF-8 -ENV LC_ALL en_US.UTF-8 +ENV LANG "en_US.UTF-8" +ENV LC_ALL "en_US.UTF-8" # change system local time RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime @@ -30,6 +23,7 @@ RUN yum install -y git RUN yum install -y gcc RUN yum install -y make RUN yum install -y wget +RUN yum install -y which RUN yum install -y screen RUN yum install -y gcc-c++ RUN yum install -y crontabs @@ -37,18 +31,21 @@ RUN yum install -y zlib-devel RUN yum install -y sqlite-devel RUN yum install -y openssl-devel RUN yum install -y libSM.x86_64 -RUN yum install -y libXrender.x86_64 RUN yum install -y libXext.x86_64 +RUN yum install -y libXrender.x86_64 + +# install node +RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - +RUN yum install -y nodejs + +# install epel +RUN yum install -y epel-release # install python -RUN yum install -y https://centos6.iuscommunity.org/ius-release.rpm -# RUN yum install -y https://centos7.iuscommunity.org/ius-release.rpm -RUN yum install -y python36u -RUN yum install -y python36u-pip -RUN yum install -y python36u-devel +RUN yum install -y python36 +RUN yum install -y python36-devel # install nginx -RUN yum install -y epel-release RUN yum install -y nginx # clean yum cache @@ -57,11 +54,8 @@ RUN yum clean all # install libs of python3 ADD ./requirements.txt /root/ WORKDIR /root/ -# RUN pip3.6 install --upgrade pip -# RUN pip3.6 install -r requirements.txt +# RUN pip3.6 install --upgrade pip -i http://pypi.douban.com/simple/ +# RUN pip3.6 install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ -# centos6 +# entry CMD /bin/bash - -# centos7 -# ENTRYPOINT /usr/sbin/init From d7c0abd923a5d56256a93755d74bd031c99e37c8 Mon Sep 17 00:00:00 2001 From: qixianhu Date: Sat, 17 Apr 2021 18:21:18 +0800 Subject: [PATCH 06/15] update dockerfile --- Docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 0b7c66b..20576c5 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,6 +1,6 @@ # Dockerfile by xianhu: build a docker image -# docker build -t user/centos:v7.8.1 . -# docker run -it --name test [-p -v] user/centos:v7.8.1 +# docker build -t xianhu/centos:v7.8.2 . +# docker run -it --name test [-p -v] xianhu/centos:v7.8.2 FROM centos:7.8.2003 MAINTAINER xianhu From 0a8eee20141cbc5143a1d8211a5774334d36166f Mon Sep 17 00:00:00 2001 From: qixianhu Date: Tue, 25 May 2021 15:22:55 +0800 Subject: [PATCH 07/15] =?UTF-8?q?docker=20=E6=B7=BB=E5=8A=A0=E7=89=B9?= =?UTF-8?q?=E6=9D=83=E6=A8=A1=E5=BC=8F=E8=BF=90=E8=A1=8C=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docker/Dockerfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 20576c5..765b751 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,6 +1,12 @@ # Dockerfile by xianhu: build a docker image # docker build -t xianhu/centos:v7.8.2 . -# docker run -it --name test [-p -v] xianhu/centos:v7.8.2 + +# 普通进入 +# docker run -it --name test [-p -v] xianhu/centos:v7.8.2 (ctrl+p/q即可退出,attach重新进入) + +# 特权进入 +# docker run -it --name test -d [-p -v] --privileged=true xianhu/centos:v7.8.2 /usr/sbin/init +# docker exec -it test /bin/bash (不能使用attach进入,退出直接exit即可) FROM centos:7.8.2003 MAINTAINER xianhu From 3a898bb8005365487291905f74364808317fdefe Mon Sep 17 00:00:00 2001 From: qixianhu Date: Wed, 25 Aug 2021 16:40:54 +0800 Subject: [PATCH 08/15] add celery --- Docker/Dockerfile | 1 - python_celery.py | 21 +++++++++++++++++++++ python_celery_test.py | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 python_celery.py create mode 100644 python_celery_test.py diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 765b751..ea934a4 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -9,7 +9,6 @@ # docker exec -it test /bin/bash (不能使用attach进入,退出直接exit即可) FROM centos:7.8.2003 -MAINTAINER xianhu # change system environments ENV LANG "en_US.UTF-8" diff --git a/python_celery.py b/python_celery.py new file mode 100644 index 0000000..c653eb8 --- /dev/null +++ b/python_celery.py @@ -0,0 +1,21 @@ +# _*_ coding: utf-8 _*_ + +""" +测试celery +运行: +""" + +import time +from celery import Celery + +broker = 'redis://152.136.149.221:9002/10' # 用redis做broker,中间件 +backend = 'redis://152.136.149.221:9002/11' # 用redis做broken,用来保存结果 + +app = Celery('tasks',broker=broker,backend=backend) + +@app.task +def add(x, y): + print(time.time(), x, y) + time.sleep(3) + print(time.time(), x, y, "--") + return x + y diff --git a/python_celery_test.py b/python_celery_test.py new file mode 100644 index 0000000..8f158c5 --- /dev/null +++ b/python_celery_test.py @@ -0,0 +1,17 @@ +# _*_ coding: utf-8 _*_ + +""" +测试 +""" + +import time +from python_celery import add + +if __name__ == "__main__": + result = [] + for i in range(10): + result.append(add.delay(1, 2)) + print("----", time.time()) + for i in result: + print(i, i.get()) + print("----", time.time()) \ No newline at end of file From fd8fce73ac9d938d7e62913d3216a7a0d8b33c24 Mon Sep 17 00:00:00 2001 From: qixianhu Date: Sat, 28 Aug 2021 13:43:42 +0800 Subject: [PATCH 09/15] add celery --- python_celery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_celery.py b/python_celery.py index c653eb8..1644ab6 100644 --- a/python_celery.py +++ b/python_celery.py @@ -2,7 +2,7 @@ """ 测试celery -运行: +运行:celery -A celery1:app worker -l INFO """ import time From 17e4369ba57d29f801accb1d16a778d62af90d07 Mon Sep 17 00:00:00 2001 From: qixianhu Date: Sat, 18 Sep 2021 22:32:57 +0800 Subject: [PATCH 10/15] =?UTF-8?q?=E5=8D=87=E7=BA=A7dockerfile=20python3.8?= =?UTF-8?q?=20-=20centos:v7.8.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docker/Dockerfile | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index ea934a4..3f48ae0 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,13 +1,14 @@ # Dockerfile by xianhu: build a docker image -# docker build -t xianhu/centos:v7.8.2 . +# docker build --rm -t xianhu/centos:v7.8.3 . # 普通进入 -# docker run -it --name test [-p -v] xianhu/centos:v7.8.2 (ctrl+p/q即可退出,attach重新进入) +# docker run -it --name test [-p -v] xianhu/centos:v7.8.3 (ctrl+p/q即可退出,attach重新进入) # 特权进入 -# docker run -it --name test -d [-p -v] --privileged=true xianhu/centos:v7.8.2 /usr/sbin/init +# docker run -it --name test -d [-p -v] --privileged=true xianhu/centos:v7.8.3 /usr/sbin/init # docker exec -it test /bin/bash (不能使用attach进入,退出直接exit即可) +# 基础镜像 FROM centos:7.8.2003 # change system environments @@ -35,6 +36,8 @@ RUN yum install -y crontabs RUN yum install -y zlib-devel RUN yum install -y sqlite-devel RUN yum install -y openssl-devel +RUN yum install -y bzip2-devel +RUN yum install -y libffi-devel RUN yum install -y libSM.x86_64 RUN yum install -y libXext.x86_64 RUN yum install -y libXrender.x86_64 @@ -47,20 +50,24 @@ RUN yum install -y nodejs RUN yum install -y epel-release # install python -RUN yum install -y python36 -RUN yum install -y python36-devel +COPY ./Python-3.8.12.tgz /root +WORKDIR /root +RUN tar xvzf Python-3.8.12.tgz +WORKDIR /root/Python-3.8.12 +RUN ./configure +RUN make && make install + +# clean root +WORKDIR /root/ +RUN rm -rf /root/* # install nginx RUN yum install -y nginx # clean yum cache RUN yum clean all - -# install libs of python3 -ADD ./requirements.txt /root/ -WORKDIR /root/ -# RUN pip3.6 install --upgrade pip -i http://pypi.douban.com/simple/ -# RUN pip3.6 install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ +# RUN python3 -m pip install --upgrade pip -i http://pypi.douban.com/simple/ +# RUN python3 -m pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ # entry -CMD /bin/bash +CMD /bin/bash \ No newline at end of file From a2c31e142c74cc8ee46ea4a384b76dbf37b3b586 Mon Sep 17 00:00:00 2001 From: qixianhu Date: Wed, 22 Sep 2021 16:35:00 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E5=8D=87=E7=BA=A7dockerfile=20=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E5=8C=85=E5=A4=A7=E5=B0=8F=EF=BC=8C=E5=8E=BB=E9=99=A4?= =?UTF-8?q?Nginx=EF=BC=8Cnodejs=E7=AD=89=E3=80=82=20v7.8.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docker/Dockerfile | 80 +++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 47 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 3f48ae0..90c753c 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,11 +1,12 @@ # Dockerfile by xianhu: build a docker image -# docker build --rm -t xianhu/centos:v7.8.3 . +# docker build --rm -t xianhu/centos:v7.8.4 . # 普通进入 -# docker run -it --name test [-p -v] xianhu/centos:v7.8.3 (ctrl+p/q即可退出,attach重新进入) +# docker run -it --name test [-p -v] xianhu/centos:v7.8.4 /bin/bash +# docker attach test (ctrl+p/q即可退出,attach重新进入) # 特权进入 -# docker run -it --name test -d [-p -v] --privileged=true xianhu/centos:v7.8.3 /usr/sbin/init +# docker run -it --name test [-p -v] -d --privileged=true xianhu/centos:v7.8.4 # docker exec -it test /bin/bash (不能使用attach进入,退出直接exit即可) # 基础镜像 @@ -15,59 +16,44 @@ FROM centos:7.8.2003 ENV LANG "en_US.UTF-8" ENV LC_ALL "en_US.UTF-8" -# change system local time -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime - -# fix: warning: rpmts_HdrFromFdno -RUN rpm --import /etc/pki/rpm-gpg/RPM* +# change system local time, fix: warning: rpmts_HdrFromFdno +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ + rpm --import /etc/pki/rpm-gpg/RPM* # update yum and install something -RUN yum update -y -RUN yum install -y xz -RUN yum install -y vim -RUN yum install -y git -RUN yum install -y gcc -RUN yum install -y make -RUN yum install -y wget -RUN yum install -y which -RUN yum install -y screen -RUN yum install -y gcc-c++ -RUN yum install -y crontabs -RUN yum install -y zlib-devel -RUN yum install -y sqlite-devel -RUN yum install -y openssl-devel -RUN yum install -y bzip2-devel -RUN yum install -y libffi-devel -RUN yum install -y libSM.x86_64 -RUN yum install -y libXext.x86_64 -RUN yum install -y libXrender.x86_64 - -# install node -RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - -RUN yum install -y nodejs - -# install epel -RUN yum install -y epel-release +RUN yum update -y && \ + yum install -y xz \ + vim \ + git \ + gcc \ + make \ + wget \ + which \ + screen \ + gcc-c++ \ + crontabs \ + zlib-devel \ + sqlite-devel \ + openssl-devel \ + bzip2-devel \ + libffi-devel \ + libSM.x86_64 \ + libXext.x86_64 \ + libXrender.x86_64 # install python -COPY ./Python-3.8.12.tgz /root -WORKDIR /root +COPY ./Python-3.8.12.tgz /root/ +WORKDIR /root/ RUN tar xvzf Python-3.8.12.tgz -WORKDIR /root/Python-3.8.12 -RUN ./configure -RUN make && make install - -# clean root +WORKDIR /root/Python-3.8.12/ +RUN ./configure && make && make install WORKDIR /root/ -RUN rm -rf /root/* -# install nginx -RUN yum install -y nginx +# clean root and yum cache +RUN rm -rf /root/* && yum clean all -# clean yum cache -RUN yum clean all # RUN python3 -m pip install --upgrade pip -i http://pypi.douban.com/simple/ # RUN python3 -m pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ # entry -CMD /bin/bash \ No newline at end of file +CMD /usr/sbin/init \ No newline at end of file From d41a2f2670164991459a2aa4766b113e87ecc4da Mon Sep 17 00:00:00 2001 From: qixianhu Date: Thu, 23 Sep 2021 11:33:48 +0800 Subject: [PATCH 12/15] =?UTF-8?q?=E5=8D=87=E7=BA=A7dockerfile,=20=E5=AF=B9?= =?UTF-8?q?=E5=A4=96=E6=9A=B4=E9=9C=B2=E7=AB=AF=E5=8F=A38088,=20v7.8.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docker/Dockerfile | 15 ++++++------- Docker/requirements.txt | 49 ----------------------------------------- 2 files changed, 7 insertions(+), 57 deletions(-) delete mode 100644 Docker/requirements.txt diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 90c753c..eed3081 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,13 +1,12 @@ # Dockerfile by xianhu: build a docker image -# docker build --rm -t xianhu/centos:v7.8.4 . -# 普通进入 -# docker run -it --name test [-p -v] xianhu/centos:v7.8.4 /bin/bash -# docker attach test (ctrl+p/q即可退出,attach重新进入) +# 构建镜像 +# docker build --rm -t xianhu/centos:v7.8.5 . # 特权进入 -# docker run -it --name test [-p -v] -d --privileged=true xianhu/centos:v7.8.4 +# docker run --name test [-p -v] -d --privileged=true xianhu/centos:v7.8.5 # docker exec -it test /bin/bash (不能使用attach进入,退出直接exit即可) +# docker exec test pwd (也可以直接执行命令) # 基础镜像 FROM centos:7.8.2003 @@ -47,13 +46,13 @@ WORKDIR /root/ RUN tar xvzf Python-3.8.12.tgz WORKDIR /root/Python-3.8.12/ RUN ./configure && make && make install -WORKDIR /root/ # clean root and yum cache +WORKDIR /root/ RUN rm -rf /root/* && yum clean all -# RUN python3 -m pip install --upgrade pip -i http://pypi.douban.com/simple/ -# RUN python3 -m pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ +# expose +EXPOSE 8088 # entry CMD /usr/sbin/init \ No newline at end of file diff --git a/Docker/requirements.txt b/Docker/requirements.txt deleted file mode 100644 index 9e92142..0000000 --- a/Docker/requirements.txt +++ /dev/null @@ -1,49 +0,0 @@ -pylint -virtualenv - -lxml -html5lib -xmltodict -pybloom_live -fake-useragent -beautifulsoup4 - -aiohttp -requests -websocket-client - -redis -PyMySQL -elasticsearch - -Flask -Flask-WTF -Flask-Mail -Flask-Login -Flask-Moment -Flask-Script -Flask-RESTful -Flask-Migrate -Flask-HTTPAuth -Flask-Bootstrap -Flask-SQLAlchemy - -dash -dash-table -dash-core-components -dash-html-components -dash-bootstrap-components - -uWSGI -gunicorn - -numpy -scipy -pandas -plotly -jupyter -matplotlib -scikit-learn - -Pillow -opencv-python From 74a2d52ef26134af00d94a8b88d0476de79761e7 Mon Sep 17 00:00:00 2001 From: qixianhu Date: Sun, 26 Sep 2021 16:55:23 +0800 Subject: [PATCH 13/15] =?UTF-8?q?=E5=88=A0=E9=99=A4docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docker/Dockerfile | 58 ----------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 Docker/Dockerfile diff --git a/Docker/Dockerfile b/Docker/Dockerfile deleted file mode 100644 index eed3081..0000000 --- a/Docker/Dockerfile +++ /dev/null @@ -1,58 +0,0 @@ -# Dockerfile by xianhu: build a docker image - -# 构建镜像 -# docker build --rm -t xianhu/centos:v7.8.5 . - -# 特权进入 -# docker run --name test [-p -v] -d --privileged=true xianhu/centos:v7.8.5 -# docker exec -it test /bin/bash (不能使用attach进入,退出直接exit即可) -# docker exec test pwd (也可以直接执行命令) - -# 基础镜像 -FROM centos:7.8.2003 - -# change system environments -ENV LANG "en_US.UTF-8" -ENV LC_ALL "en_US.UTF-8" - -# change system local time, fix: warning: rpmts_HdrFromFdno -RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ - rpm --import /etc/pki/rpm-gpg/RPM* - -# update yum and install something -RUN yum update -y && \ - yum install -y xz \ - vim \ - git \ - gcc \ - make \ - wget \ - which \ - screen \ - gcc-c++ \ - crontabs \ - zlib-devel \ - sqlite-devel \ - openssl-devel \ - bzip2-devel \ - libffi-devel \ - libSM.x86_64 \ - libXext.x86_64 \ - libXrender.x86_64 - -# install python -COPY ./Python-3.8.12.tgz /root/ -WORKDIR /root/ -RUN tar xvzf Python-3.8.12.tgz -WORKDIR /root/Python-3.8.12/ -RUN ./configure && make && make install - -# clean root and yum cache -WORKDIR /root/ -RUN rm -rf /root/* && yum clean all - -# expose -EXPOSE 8088 - -# entry -CMD /usr/sbin/init \ No newline at end of file From 57988b3de0a7e12c68e5f80e74efd1f68055d990 Mon Sep 17 00:00:00 2001 From: qixianhu Date: Wed, 13 Apr 2022 22:27:54 +0800 Subject: [PATCH 14/15] update celery --- python_celery.py | 10 ++++++---- python_celery_test.py | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/python_celery.py b/python_celery.py index 1644ab6..f7c8f9a 100644 --- a/python_celery.py +++ b/python_celery.py @@ -2,16 +2,18 @@ """ 测试celery -运行:celery -A celery1:app worker -l INFO +终端运行:celery -A python_celery:app worker -l INFO """ import time + from celery import Celery -broker = 'redis://152.136.149.221:9002/10' # 用redis做broker,中间件 -backend = 'redis://152.136.149.221:9002/11' # 用redis做broken,用来保存结果 +broker = "redis://localhost:6379/10" # 用redis做broker,中间件 +backend = "redis://localhost:6379/11" # 用redis做broken,用来保存结果 + +app = Celery("tasks", broker=broker, backend=backend) -app = Celery('tasks',broker=broker,backend=backend) @app.task def add(x, y): diff --git a/python_celery_test.py b/python_celery_test.py index 8f158c5..f3d1dbc 100644 --- a/python_celery_test.py +++ b/python_celery_test.py @@ -5,13 +5,14 @@ """ import time + from python_celery import add if __name__ == "__main__": result = [] for i in range(10): - result.append(add.delay(1, 2)) + result.append(add.delay(i, i)) + print("----", time.time()) + for index, item in enumerate(result): + print(index, item.get()) print("----", time.time()) - for i in result: - print(i, i.get()) - print("----", time.time()) \ No newline at end of file From 65e027f1bbbf1d840b74c85958a9b7700ca49881 Mon Sep 17 00:00:00 2001 From: hsy <2933206210@qq.com> Date: Sat, 2 Nov 2024 16:49:53 +0800 Subject: [PATCH 15/15] python_re --- README.md | 2 ++ python_re.py | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 python_re.py diff --git a/README.md b/README.md index 50bd2af..812e234 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ ### python_socket.py: Python的socket开发实例 +### python_re.py:Python的re模块的主要功能以及如何使用它们进行字符串匹配和替换 + ### Plotly目录: 一些plotly画图的实例,使用jupyter notebook编写 =================================================================================================== diff --git a/python_re.py b/python_re.py new file mode 100644 index 0000000..4e548f6 --- /dev/null +++ b/python_re.py @@ -0,0 +1,83 @@ +import re + +#-- 基本正则表达式语法 +''' +.:匹配除换行符以外的任意字符。 +^:匹配字符串的开始。 +$:匹配字符串的结束。 +*:匹配前一个字符0次或多次。 ++:匹配前一个字符1次或多次。 +?:匹配前一个字符0次或1次。 +{m}:匹配前一个字符m次。 +{m,n}:匹配前一个字符至少m次,至多n次。 +[abc]:匹配字符集合中的任意一个字符(例如a、b或c)。 +[^abc]:匹配不在字符集合中的任意字符。 +|:表示“或”关系,匹配符号前后的任意一个表达式。 +():用于分组,可以提取匹配的部分。 +\d:匹配任意数字,等价于[0-9]。 +\D:匹配任意非数字字符,等价于[^0-9]。 +\w:匹配任意字母数字字符,包括下划线,等价于[a-zA-Z0-9_]。 +\W:匹配任意非字母数字字符,等价于[^a-zA-Z0-9_]。 +\s:匹配任意空白字符,包括空格、制表符、换行符等。 +\S:匹配任意非空白字符。 +''' + +#-- re 模块的主要函数 +re.match(pattern, string, flags=0) # 尝试从字符串的起始位置匹配正则表达式,如果匹配成功,返回一个匹配对象;否则返回None。 +re.search(pattern, string, flags=0) # 扫描整个字符串,返回第一个成功匹配的对象;否则返回None。 +re.findall(pattern, string, flags=0) # 在字符串中找到所有与正则表达式匹配的非重叠匹配项,并返回一个列表。 +re.finditer(pattern, string, flags=0) # 与findall类似,但返回的是一个迭代器,每个迭代元素都是一个匹配对象。 +re.sub(pattern, repl, string, count=0, flags=0) # 使用repl替换string中所有与pattern匹配的子串,count表示替换的最大次数。 +re.subn(pattern, repl, string, count=0, flags=0) # 功能与sub相同,但返回一个元组,包含替换后的字符串和替换的总次数。 +re.split(pattern, string, maxsplit=0, flags=0) # 根据正则表达式的模式分割字符串,maxsplit表示分割的最大次数。 +re.escape(string) # 对字符串中的非字母数字字符进行转义,使其可以安全地用于正则表达式中。 + +#-- 示例代码1 +# 匹配字符串的开始 +match_obj = re.match(r'^Hello', 'Hello World') +if match_obj: + print("Match found:", match_obj.group()) +else: + print("No match") + +# 搜索字符串 +search_obj = re.search(r'World', 'Hello World') +if search_obj: + print("Search found:", search_obj.group()) +else: + print("No search match") + +# 查找所有匹配项 +findall_result = re.findall(r'\d+', 'There are 42 apples and 33 oranges') +print("Findall result:", findall_result) + +# 替换匹配项 +sub_result = re.sub(r'\d+', 'many', 'There are 42 apples and 33 oranges') +print("Sub result:", sub_result) + +# 分割字符串 +split_result = re.split(r'\s+', 'Hello World this is Python') +print("Split result:", split_result) + +# 转义字符串 +escaped_string = re.escape('Hello? World!') +print("Escaped string:", escaped_string) + +#-- 标志位(flags) +re.IGNORECASE # 忽略大小写。 +re.MULTILINE # 多行模式,改变^和$的行为。 +re.DOTALL # 让.匹配包括换行符在内的所有字符。 +re.VERBOSE # 允许正则表达式包含空白和注释,使其更易于阅读。 + +#-- 示例代码2 +pattern = re.compile(r''' + \d+ # 匹配一个或多个数字 + \. # 匹配小数点 + \d+ # 匹配一个或多个数字 +''', re.VERBOSE) + +match_obj = pattern.match('123.456') +if match_obj: + print("Match found:", match_obj.group()) +else: + print("No match") \ No newline at end of file