python 操作asdl
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import win32ras
import time,os
def Connect(dialname, account, passwd):
dial_params = (dialname, '', '', account, passwd, '')
return win32ras.Dial(None, None, dial_params, None)
def DialBroadband():
dialname = '宽带连接' #just a name
account = '057992811002'
passwd = '875645'
try:
#handle is a pid, for disconnect or showipadrress, if connect success return 0.
#account is the username that your ISP supposed, passwd is the password.
handle, result = Connect(dialname, account, passwd)
if result == 0:
print("Connection success!")
return handle, result
else:
print("Connection failed, wait for 5 seconds and try again...")
time.sleep(5)
DialBroadband()
except:
print("Can't finish this connection, please check out.")
return
def Disconnect(handle):
if handle != None:
try:
win32ras.HangUp(handle)
print("Disconnection success!")
return "success"
except:
print("Disconnection failed, wait for 5 seconds and try again...")
time.sleep(5)
Disconnect(handle)
else:
print("Can't find the process!")
return
def Check_for_Broadband():
connections = []
connections = win32ras.EnumConnections()
if(len(connections) == 0):
print("The system is not running any broadband connection.")
return
else:
print("The system is running %d broadband connection." % len(connections))
return connections
def ShowIpAddress(handle):
print(win32ras.GetConnectStatus(handle))
data = os.popen("ipconfig","r").readlines()
have_ppp = 0
ip_str = None
for line in data:
if line.find("宽带连接")>=0:
have_ppp = 1
#if your system language is English, you should write like this:
#if have_ppp and line.strip().startswith("IP Address"):
#in othewords, replace the "IPv4 地址" to "IP Address"
if have_ppp and line.strip().startswith("IPv4 地址"):
ip_str = line.split(":")[1].strip()
have_ppp = 0
print(ip_str)
#get my ipaddress anf disconnect broadband connection.
def main():
data = Check_for_Broadband()
#if exist running broadband connection, disconnected it.
if data != None:
for p in data:
ShowIpAddress(p[0])
if(Disconnect(p[0]) == "success"):
print("%s has been disconnected." % p[1])
time.sleep(0.05)
DialBroadband()
else:
pid, res = DialBroadband()
ShowIpAddress(pid)
return "finsh test"
python 操作asdl的更多相关文章
- Python(九) Python 操作 MySQL 之 pysql 与 SQLAchemy
本文针对 Python 操作 MySQL 主要使用的两种方式讲解: 原生模块 pymsql ORM框架 SQLAchemy 本章内容: pymsql 执行 sql 增\删\改\查 语句 pymsql ...
- Python 【第六章】:Python操作 RabbitMQ、Redis、Memcache、SQLAlchemy
Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度 ...
- 练习:python 操作Mysql 实现登录验证 用户权限管理
python 操作Mysql 实现登录验证 用户权限管理
- Python操作MySQL
本篇对于Python操作MySQL主要使用两种方式: 原生模块 pymsql ORM框架 SQLAchemy pymsql pymsql是Python中操作MySQL的模块,其使用方法和MySQLdb ...
- Python操作Mysql之基本操作
pymysql python操作mysql依赖pymysql这个模块 下载安装 pip3 install pymysql 操作mysql python操作mysql的时候,是通过”游标”来进行操作的. ...
- Python操作RabbitMQ
RabbitMQ介绍 RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现的产品,RabbitMQ是一个消息代理,从“生产者”接收消息并传递消 ...
- python操作日期和时间的方法
不管何时何地,只要我们编程时遇到了跟时间有关的问题,都要想到 datetime 和 time 标准库模块,今天我们就用它内部的方法,详解python操作日期和时间的方法.1.将字符串的时间转换为时间戳 ...
- Python—操作redis
Python操作redis 连接方式:点击 1.String 操作 redis中的String在在内存中按照一个name对应一个value来存储 set() #在Redis中设置值,默认不存在则创建, ...
- python成长之路【第十三篇】:Python操作MySQL之pymysql
对于Python操作MySQL主要使用两种方式: 原生模块 pymsql ORM框架 SQLAchemy pymsql pymsql是Python中操作MySQL的模块,其使用方法和MySQLdb几乎 ...
随机推荐
- Zigbee安全入门(一)—— 技术介绍和安全策略
么是Zigbee? Zigbee说白了就是类似wifi.蓝牙的一种交换数据的方式,学术点说就是低成本.用于低功耗嵌入式设备(无线电系统),用以促进机器与机器之间高效且有效通信(通常相距10-100米) ...
- memcache缓存使用详解
初始化一个Memcache的对象:$mem = new Memcache(); 连接到我们的Memcache服务器端,第一个参数是服务器的IP地址,也可以是主机名,第二个参数是Memcache的开放的 ...
- [jnhs]全套CRC校验 算法
摘自 https://blog.csdn.net/cp1300/article/details/51443350 uint8_t crc4_itu(uint8_t *data, uint_len le ...
- matplotlib无法显示中文
import matplotlib as mpl mpl.rcParams['font.sans-serif'] = ['KaiTi']mpl.rcParams['font.serif'] = ['K ...
- 洛谷P1508 Likecloud-吃、吃、吃 [2017年4月计划 动态规划10]
P1508 Likecloud-吃.吃.吃 题目背景 问世间,青春期为何物? 答曰:“甲亢,甲亢,再甲亢:挨饿,挨饿,再挨饿!” 题目描述 正处在某一特定时期之中的李大水牛由于消化系统比较发达,最近一 ...
- JavaScript-JQ实现自定义滚动条插件1.0
此滚动条仅支持竖向(Y轴) 一.Css /*这里是让用户鼠标在里面不能选中文字,避免拖动的时候出错*/ body { -moz-user-select: none; /*火狐*/ -webkit-us ...
- QT_string转char*
char* convertQString2char(const QString &str) { QByteArray ba = str.toUtf8(); char * pathChar = ...
- Vue--通过button跳转到其他组件并携带id参数
一.创建vue文件 ’ <template> <div> goodsCommon<br/> goodsCommon<br/> goodsCommon&l ...
- web前端学习常用网址记录
jetbrains下载各种软件和试用 www.jetbrains.com www.jetbrains.com/idea php服务器下载 php文档查询 php.net webAPI网站(各种教程文档 ...
- Codeforces 3D
题目链接 D. Least Cost Bracket Sequence time limit per test 1 second memory limit per test 64 megabytes ...