Commit bb846822 authored by 刘丙寅's avatar 刘丙寅

修改

parent 3bf81dea
This diff is collapsed.
import random
import redis,json
import requests
r = redis.Redis()
import peizhi
def test111():
list = r.lrange("zhiban",0,-1)
r.delete('zhiban')
print(list)
if not list:
list = ["张三","李四","王五","赵六","奉七","111"]
little_list = random.sample(list,2)
list.remove(little_list[0])
list.remove(little_list[1])
# little_list 是值班人员
r.lpush("zhiban", *list)
else:
little_list = random.sample(list, 2)
list.remove(little_list[0])
list.remove(little_list[1])
# little_list 是值班人员
if list == []:
pass
else:
r.lpush("zhiban", *list)
def demo222():
ll = ["丙寅","奉龙"]
phonenum = []
for i in ll:
phone = peizhi.Personnel_list_111.get(i)
phonenum.append(phone)
dd_url = "https://oapi.dingtalk.com/robot/send?access_token=b2f03936be10b15bd6395a2e567a4c41c0540a9f109c5046a4cdc3f85ac8e374"
text = "报警周末值班,请查看邮件排查问题"
json_text = {
"msgtype": "text",
"at": {
"atMobiles": phonenum,
# 变为true 就会@所有人
# "isAtAll": False
"isAtAll": False
},
"text": {
"content": text
}
}
requests.post(url=dd_url, json=json_text, verify=False)
def demo333():
ll = ["1","2"]
lll = ["1","2","3","5"]
lll.remove(ll)
print(lll)
if __name__ == '__main__':
demo333()
# 查出来明天休假开始 后面有多少天
# 获取到天数
# 根据天数 获取redis里面的人 如果人数不够 追加一个新列表
......@@ -37,24 +37,24 @@ def test():
# 钉钉报警
# dd_url = "https://oapi.dingtalk.com/robot/send?access_token=062ab7f98f47c85e6c200efd21ae5d532e4f1bbfd6782ae1268b9a1f4d3dc7b9"
# text = "明日开始休息:本次值班人员为:%s 值班人员记得带 电脑,手机, vpn环境" % {message}
# json_text = {
# "msgtype": "text",
# "at": {
# "atMobiles": [
#
# "all"
# ],
# # 变为true 就会@所有人
# "isAtAll": True
# },
# "text": {
# "content": text
# }
# }
#
# requests.post(url=dd_url, json=json_text, verify=False)
dd_url = "https://oapi.dingtalk.com/robot/send?access_token=062ab7f98f47c85e6c200efd21ae5d532e4f1bbfd6782ae1268b9a1f4d3dc7b9"
text = "明日开始休息:本次值班人员为:%s 值班人员记得带 电脑,手机, vpn环境" % {message}
json_text = {
"msgtype": "text",
"at": {
"atMobiles": [
"all"
],
# 变为true 就会@所有人
"isAtAll": True
},
"text": {
"content": text
}
}
requests.post(url=dd_url, json=json_text, verify=False)
......
Copyright (c) 2012 Andy McCurdy
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
redis/__init__.py,sha256=xHeEs2e5uiAwaV0oxJ_DgdOVr8U8Y5OlSCJ9rRbiLkE,1209
redis/_compat.py,sha256=opM78DdCy4D86p9cpN_O81yNgjVDUwOJGLtMS4LL9-0,5698
redis/client.py,sha256=hs1gxHDN9AcpPy1Cpf6yHq4ICtDYofW9XijXpSDeSG0,159611
redis/connection.py,sha256=B5n2unyz5YhSzhsyK9Wa_AXZjT6guxnqHdZcfbe3jqs,55954
redis/exceptions.py,sha256=phjjyJjnebrM82XDzfjtreGnkWIoSNfDZiyoWs3_zQE,1341
redis/lock.py,sha256=VNfWNN46FBwhcPUnFmzC8N8uLuxCsu2YT2drkEzM6_U,11349
redis/sentinel.py,sha256=EhyjT_tZMWKtwuUMMAIRKwfEPL1qBfoldLFQ8tAN1Dg,11710
redis/utils.py,sha256=wG1Ws79_HgIzAALwYwK4CrVLLloVTRPRqjo1gxF4U7U,674
redis-3.5.3.dist-info/LICENSE,sha256=eQFI2MEvijiycHp0viNDMWutEmmV_1SAGhgbiyMboSQ,1074
redis-3.5.3.dist-info/METADATA,sha256=55ufgygbtE8nqMl0UVKD90EZ01zKyemMdxFFOwpubC4,36674
redis-3.5.3.dist-info/WHEEL,sha256=kGT74LWyRUZrL4VgLh6_g12IeVl_9u9ZVhadrgXZUEY,110
redis-3.5.3.dist-info/top_level.txt,sha256=OMAefszlde6ZoOtlM35AWzpRIrwtcqAMHGlRit-w2-4,6
redis-3.5.3.dist-info/RECORD,,
redis-3.5.3.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
redis/__pycache__/client.cpython-37.pyc,,
redis/__pycache__/exceptions.cpython-37.pyc,,
redis/__pycache__/lock.cpython-37.pyc,,
redis/__pycache__/_compat.cpython-37.pyc,,
redis/__pycache__/connection.cpython-37.pyc,,
redis/__pycache__/sentinel.cpython-37.pyc,,
redis/__pycache__/utils.cpython-37.pyc,,
redis/__pycache__/__init__.cpython-37.pyc,,
Wheel-Version: 1.0
Generator: bdist_wheel (0.34.2)
Root-Is-Purelib: true
Tag: py2-none-any
Tag: py3-none-any
from redis.client import Redis, StrictRedis
from redis.connection import (
BlockingConnectionPool,
ConnectionPool,
Connection,
SSLConnection,
UnixDomainSocketConnection
)
from redis.utils import from_url
from redis.exceptions import (
AuthenticationError,
AuthenticationWrongNumberOfArgsError,
BusyLoadingError,
ChildDeadlockedError,
ConnectionError,
DataError,
InvalidResponse,
PubSubError,
ReadOnlyError,
RedisError,
ResponseError,
TimeoutError,
WatchError
)
def int_or_str(value):
try:
return int(value)
except ValueError:
return value
__version__ = '3.5.3'
VERSION = tuple(map(int_or_str, __version__.split('.')))
__all__ = [
'AuthenticationError',
'AuthenticationWrongNumberOfArgsError',
'BlockingConnectionPool',
'BusyLoadingError',
'ChildDeadlockedError',
'Connection',
'ConnectionError',
'ConnectionPool',
'DataError',
'from_url',
'InvalidResponse',
'PubSubError',
'ReadOnlyError',
'Redis',
'RedisError',
'ResponseError',
'SSLConnection',
'StrictRedis',
'TimeoutError',
'UnixDomainSocketConnection',
'WatchError',
]
"""Internal module for Python 2 backwards compatibility."""
# flake8: noqa
import errno
import socket
import sys
def sendall(sock, *args, **kwargs):
return sock.sendall(*args, **kwargs)
def shutdown(sock, *args, **kwargs):
return sock.shutdown(*args, **kwargs)
def ssl_wrap_socket(context, sock, *args, **kwargs):
return context.wrap_socket(sock, *args, **kwargs)
# For Python older than 3.5, retry EINTR.
if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and
sys.version_info[1] < 5):
# Adapted from https://bugs.python.org/review/23863/patch/14532/54418
import time
# Wrapper for handling interruptable system calls.
def _retryable_call(s, func, *args, **kwargs):
# Some modules (SSL) use the _fileobject wrapper directly and
# implement a smaller portion of the socket interface, thus we
# need to let them continue to do so.
timeout, deadline = None, 0.0
attempted = False
try:
timeout = s.gettimeout()
except AttributeError:
pass
if timeout:
deadline = time.time() + timeout
try:
while True:
if attempted and timeout:
now = time.time()
if now >= deadline:
raise socket.error(errno.EWOULDBLOCK, "timed out")
else:
# Overwrite the timeout on the socket object
# to take into account elapsed time.
s.settimeout(deadline - now)
try:
attempted = True
return func(*args, **kwargs)
except socket.error as e:
if e.args[0] == errno.EINTR:
continue
raise
finally:
# Set the existing timeout back for future
# calls.
if timeout:
s.settimeout(timeout)
def recv(sock, *args, **kwargs):
return _retryable_call(sock, sock.recv, *args, **kwargs)
def recv_into(sock, *args, **kwargs):
return _retryable_call(sock, sock.recv_into, *args, **kwargs)
else: # Python 3.5 and above automatically retry EINTR
def recv(sock, *args, **kwargs):
return sock.recv(*args, **kwargs)
def recv_into(sock, *args, **kwargs):
return sock.recv_into(*args, **kwargs)
if sys.version_info[0] < 3:
# In Python 3, the ssl module raises socket.timeout whereas it raises
# SSLError in Python 2. For compatibility between versions, ensure
# socket.timeout is raised for both.
import functools
try:
from ssl import SSLError as _SSLError
except ImportError:
class _SSLError(Exception):
"""A replacement in case ssl.SSLError is not available."""
pass
_EXPECTED_SSL_TIMEOUT_MESSAGES = (
"The handshake operation timed out",
"The read operation timed out",
"The write operation timed out",
)
def _handle_ssl_timeout(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except _SSLError as e:
message = len(e.args) == 1 and unicode(e.args[0]) or ''
if any(x in message for x in _EXPECTED_SSL_TIMEOUT_MESSAGES):
# Raise socket.timeout for compatibility with Python 3.
raise socket.timeout(*e.args)
raise
return wrapper
recv = _handle_ssl_timeout(recv)
recv_into = _handle_ssl_timeout(recv_into)
sendall = _handle_ssl_timeout(sendall)
shutdown = _handle_ssl_timeout(shutdown)
ssl_wrap_socket = _handle_ssl_timeout(ssl_wrap_socket)
if sys.version_info[0] < 3:
from urllib import unquote
from urlparse import parse_qs, urlparse
from itertools import imap, izip
from string import letters as ascii_letters
from Queue import Queue
# special unicode handling for python2 to avoid UnicodeDecodeError
def safe_unicode(obj, *args):
""" return the unicode representation of obj """
try:
return unicode(obj, *args)
except UnicodeDecodeError:
# obj is byte string
ascii_text = str(obj).encode('string_escape')
return unicode(ascii_text)
def iteritems(x):
return x.iteritems()
def iterkeys(x):
return x.iterkeys()
def itervalues(x):
return x.itervalues()
def nativestr(x):
return x if isinstance(x, str) else x.encode('utf-8', 'replace')
def next(x):
return x.next()
unichr = unichr
xrange = xrange
basestring = basestring
unicode = unicode
long = long
BlockingIOError = socket.error
else:
from urllib.parse import parse_qs, unquote, urlparse
from string import ascii_letters
from queue import Queue
def iteritems(x):
return iter(x.items())
def iterkeys(x):
return iter(x.keys())
def itervalues(x):
return iter(x.values())
def nativestr(x):
return x if isinstance(x, str) else x.decode('utf-8', 'replace')
def safe_unicode(value):
if isinstance(value, bytes):
value = value.decode('utf-8', 'replace')
return str(value)
next = next
unichr = chr
imap = map
izip = zip
xrange = range
basestring = str
unicode = str
long = int
BlockingIOError = BlockingIOError
try: # Python 3
from queue import LifoQueue, Empty, Full
except ImportError: # Python 2
from Queue import LifoQueue, Empty, Full
This diff is collapsed.
This diff is collapsed.
"Core exceptions raised by the Redis client"
class RedisError(Exception):
pass
class ConnectionError(RedisError):
pass
class TimeoutError(RedisError):
pass
class AuthenticationError(ConnectionError):
pass
class BusyLoadingError(ConnectionError):
pass
class InvalidResponse(RedisError):
pass
class ResponseError(RedisError):
pass
class DataError(RedisError):
pass
class PubSubError(RedisError):
pass
class WatchError(RedisError):
pass
class NoScriptError(ResponseError):
pass
class ExecAbortError(ResponseError):
pass
class ReadOnlyError(ResponseError):
pass
class NoPermissionError(ResponseError):
pass
class LockError(RedisError, ValueError):
"Errors acquiring or releasing a lock"
# NOTE: For backwards compatability, this class derives from ValueError.
# This was originally chosen to behave like threading.Lock.
pass
class LockNotOwnedError(LockError):
"Error trying to extend or release a lock that is (no longer) owned"
pass
class ChildDeadlockedError(Exception):
"Error indicating that a child process is deadlocked after a fork()"
pass
class AuthenticationWrongNumberOfArgsError(ResponseError):
"""
An error to indicate that the wrong number of args
were sent to the AUTH command
"""
pass
This diff is collapsed.
This diff is collapsed.
from contextlib import contextmanager
try:
import hiredis # noqa
HIREDIS_AVAILABLE = True
except ImportError:
HIREDIS_AVAILABLE = False
def from_url(url, db=None, **kwargs):
"""
Returns an active Redis client generated from the given database URL.
Will attempt to extract the database id from the path url fragment, if
none is provided.
"""
from redis.client import Redis
return Redis.from_url(url, db, **kwargs)
@contextmanager
def pipeline(redis_obj):
p = redis_obj.pipeline()
yield p
p.execute()
class dummy(object):
"""
Instances of this class can be used as an attribute container.
"""
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment