コード例 #1
0
def push_player_stats(player_stats):
    endpoint = Mock()
    instance = Push(endpoint)
    instance.player_stats(player_stats)
    key = player_stats['date']

    endpoint.put.assert_any_call('/stats/', key, player_stats)
コード例 #2
0
def push_foreach_match(list_of_match):
    endpoint = Mock()
    instance = Push(endpoint)
    instance.matches(list_of_match)

    for m in list_of_match:
        endpoint.put.assert_any_call('/matches/', m['match_id'], m)
コード例 #3
0
ファイル: main.py プロジェクト: Netekss/Python-forex-event
def run_main(events):
    while True:
        current_time = GetTime().get_current_time()

        for event in events:
            if (event['time'] > current_time) and (event['time'] < (current_time + datetime.timedelta(hours=1))):
                incoming_events.append(event)

        if len(incoming_events) == 0:
            push = Push(str(current_time), 'No incoming events within an hour')
            push.auto_select_os()
        else:
            for incoming_event in incoming_events:
                push = Push(f"Incoming event at {str(incoming_event['time'])}", incoming_event['name'])
                push.auto_select_os()

        incoming_events.clear()
        time.sleep(3200)
コード例 #4
0
def index():
    try:
        payload = loads(request.data)

        text = Push(payload)
        text.process()
        Bot.sendMessage(CHAT_ID, text.message)
    except:
        abort(400)

    return "Ok!"
コード例 #5
0
ファイル: main.py プロジェクト: cskeppstedt/larz-server
def publish():
    auth = firebase.FirebaseAuthentication(vars.SECRET, vars.EMAIL)
    endpoint = firebase.FirebaseApplication(vars.FB_URL)
    endpoint.authentication = auth

    post = {
        'embed_url': 'https://www.youtube.com/embed/UVsIGAEnK_4',
        'post_id': '2',
        'published': '2015-03-14 19:10'
    }

    Push(endpoint).post(post)
コード例 #6
0
 def __init__(self):
     self.closed = False
     self.command = str()
     self.args = defaultdict(list)
     self.command_history = list()
     self.valid_commands = {}
     self.valid_commands["init"] = Init()
     self.valid_commands["push"] = Push()
     self.valid_commands["pull"] = Pull()
     self.valid_commands["config"] = Config()
     self.valid_commands["dir"] = Dir()
     self.valid_commands["purgue"] = Purgue()
コード例 #7
0
ファイル: main.py プロジェクト: cskeppstedt/larz-server
def players():
    log('players', "fetching player_stats for %d users" % len(vars.USERS))

    stats = Poll().player_stats(vars.USERS)
    if len(stats) == 0:
        log('players', 'no stats, exiting')
        return

    log('players', "recieved %d stats entries" % len(stats))

    auth = firebase.FirebaseAuthentication(vars.SECRET, vars.EMAIL)
    endpoint = firebase.FirebaseApplication(vars.FB_URL)
    endpoint.authentication = auth

    Push(endpoint).player_stats(stats)
    log('players', "pushed %d stats entries to firebase" % len(stats))
コード例 #8
0
ファイル: main.py プロジェクト: cskeppstedt/larz-server
def matches():
    log('matches', 'fetching stats for %d users' % len(vars.USERS))

    tokens = Poll().match_tokens(vars.USERS)
    if len(tokens) == 0:
        log('matches', 'no tokens, exiting')
        return

    matches = Poll().matches(tokens)
    if len(matches) == 0:
        log('matches', 'no matches, exiting')
        return

    log('matches', "recieved %d match tokens" % len(matches))

    auth = firebase.FirebaseAuthentication(vars.SECRET, vars.EMAIL)
    endpoint = firebase.FirebaseApplication(vars.FB_URL)
    endpoint.authentication = auth

    Push(endpoint).matches(matches)
    log('matches', "pushed %d matches to firebase" % len(matches))
コード例 #9
0
def query_pushes_by_revision_range(repo_url,
                                   from_revision,
                                   to_revision,
                                   version=VERSION,
                                   tipsonly=True,
                                   return_revision_list=False):
    """
    Return an ordered list of pushes (by date - oldest (starting) first).

    repo_url                - represents the URL to clone a repo
    from_revision           - from which revision to start with (oldest)
    to_revision             - from which revision to end with (newest)
    version                 - version of json-pushes to use (see docs)
    tipsonly                - only return the tip most push been returned if it's True
    return_revision_list    - return a list of revisions if it's True
    """
    push_list = []
    url = "%s?fromchange=%s&tochange=%s&version=%d" % (JSON_PUSHES % {
        "repo_url": repo_url
    }, from_revision, to_revision, version)

    if tipsonly:
        url += '&tipsonly=1'

    LOG.debug("About to fetch %s" % url)
    req = retry(requests.get, args=(url, ))
    pushes = req.json()["pushes"]
    # json-pushes does not include the starting revision
    push_list.append(query_push_by_revision(repo_url, from_revision))

    for push_id in sorted(pushes.keys()):
        # Querying by push ID is perferred because date ordering is
        # not guaranteed (due to system clock skew)
        # We can interact with self-serve with the full char representation
        push_list.append(Push(push_id=push_id, push_info=pushes[push_id]))
    if return_revision_list:
        return _pushes_to_list(push_list)

    return push_list
コード例 #10
0
def query_push_by_revision(repo_url,
                           revision,
                           full=False,
                           return_revision_list=False):
    """
    Return a dictionary with meta-data about a push including:

        * changesets
        * date
        * user
    repo_url               - represents the URL to clone a rep
    revision               - the revision used to set the query range
    full                   - query whole information of a push if it's True
    return_revision_list   - return a list of revisions if it's True
    """
    url = "%s?changeset=%s&tipsonly=1" % (JSON_PUSHES % {
        "repo_url": repo_url
    }, revision)
    if full:
        url += "&full=1"
    LOG.debug("About to fetch %s" % url)
    req = retry(requests.get, args=(url, ))
    data = req.json()
    assert len(data) == 1, "We should only have information about one push"

    if not full:
        LOG.debug("Push info: %s" % str(data))
        push_id, push_info = data.popitem()
        push = Push(push_id=push_id, push_info=push_info)
    else:
        LOG.debug(
            "Requesting the info with full=1 can yield too much unnecessary output "
            "to debug anything properly")
    if return_revision_list:
        return push.changesets[0].node

    return push
コード例 #11
0
def query_pushes_by_pushid_range(repo_url,
                                 start_id,
                                 end_id,
                                 version=VERSION,
                                 return_revision_list=False):
    """
    Return an ordered list of pushes (oldest first).

    repo_url               - represents the URL to clone a repo
    start_id               - from which pushid to start with (oldest)
    end_id                 - from which pushid to end with (most recent)
    version                - version of json-pushes to use (see docs)
    return_revision_list   - return a list of revisions if it's True
    """
    push_list = []
    url = "%s?startID=%s&endID=%s&version=%s&tipsonly=1" % (
        JSON_PUSHES % {
            "repo_url": repo_url
        },
        start_id -
        1,  # off by one to compensate for pushlog as it skips start_id
        end_id,
        version)
    LOG.debug("About to fetch %s" % url)
    req = retry(requests.get, args=(url, ))
    pushes = req.json()["pushes"]

    for push_id in sorted(pushes.keys()):
        # Querying by push ID is preferred because date ordering is
        # not guaranteed (due to system clock skew)
        # We can interact with self-serve with the 12 char representation
        push_list.append(Push(push_id=push_id, push_info=pushes[push_id]))
    if return_revision_list:
        return _pushes_to_list(push_list)

    return push_list
コード例 #12
0
ファイル: main.py プロジェクト: zhangfei28/WeiboSender
import logging, logging.config
import json
import config
from message import Message
from push import Push
from weibo import Weibo
import traceback
import random
import time
from api import app

conf = json.loads(config.LoggerJsonConfig)
logging.config.dictConfig(conf)

log = logging.getLogger('main')
push = Push(config.DingTalkWebHookToken)


def callback(path):
    url = config.Url + path + '?rand=%d' % random.randrange(10000)
    title = '微博登陆提醒'
    text = '![.](%s)' % url
    push.push(title, text, config.DingTalkWebHookAtPhone)


def main():
    queue = Message(config.Redis, config.RedisKey)
    weibo = Weibo(config.ChromeDriver, callback)
    while True:
        try:
            msg = queue.getMessage()
コード例 #13
0
def push_post(a_post):
    endpoint = Mock()
    instance = Push(endpoint)
    instance.post(a_post)

    endpoint.put.assert_any_call('/posts/', a_post['post_id'], a_post)
コード例 #14
0
def query_repo_tip(repo_url):
    """Return the tip of a branch URL."""
    url = "%s?tipsonly=1" % (JSON_PUSHES % {"repo_url": repo_url})
    recent_commits = retry(requests.get, args=(url, )).json()
    tip_id = sorted(recent_commits.keys())[-1]
    return Push(push_id=tip_id, push_info=recent_commits[tip_id])
コード例 #15
0
ファイル: main.py プロジェクト: koumolin/2019-nCoV-Push
                    time.sleep(20)
    except Exception as e:
        log.error("error: %s", traceback.format_exc())


if __name__ == '__main__':
    # use github action to run?
    if len(sys.argv) > 1:
        usrAction = True
        log.info("use github action")
    else:
        usrAction = False

    push = Push(token=config.PushToken,
                keyWord=config.PushKeyWord,
                weiboSCF=config.WeiboSCFUrl,
                weiboRef=config.WeiboRef,
                weiboCookie=config.WeiboCookie,
                weixinToken=config.WeixinToken)

    useMirror = False if config.TelegramMirror is None else True

    if not useMirror:
        spider = Spider()
    else:
        spider = SpiderMirror(config.TelegramMirror)

    cityFilter = config.City

    if usrAction:
        state = State(config.Redis)
        spider.postId = state.getPostId()
コード例 #16
0

def setup(app):
    push = Push(app)
    app.register_class('Push.instance', push)
    app.add_action('details_push_commit', push.render_commit_message)


if __name__ == '__main__':
    base_dir = os.path.dirname(os.path.realpath(__file__))
    sys.path.append('%s/../../' % base_dir)
    sys.path.append('%s/../../plugins/config/' % base_dir)

    from push import Push
    from config import Config
    push = Push(None)
    conf = Config(None)

    parser = argparse.ArgumentParser()
    parser.add_argument('-d',
                        '--docs',
                        help='Shows docs for this process',
                        default='',
                        nargs='?')
    args = parser.parse_args()
    docs = getattr(args, 'docs')
    if docs or docs == None:
        help(Push)
    else:
        push.term_push(conf.get_data())
コード例 #17
0
def setup(app):
    push = Push(app)
    app.register_class('Push.instance', push)
    app.add_action('details_push_commit', push.render_commit_message)