コード例 #1
0
import requests
from bs4 import BeautifulSoup

from atcodertools.client.models.submission import Submission
from atcodertools.common.language import Language
from atcodertools.fileutils.artifacts_cache import get_cache_file_path
from atcodertools.client.models.contest import Contest
from atcodertools.client.models.problem import Problem
from atcodertools.client.models.problem_content import ProblemContent, InputFormatDetectionError, SampleDetectionError


class LoginError(Exception):
    pass


default_cookie_path = get_cache_file_path('cookie.txt')


def save_cookie(session: requests.Session, cookie_path: Optional[str] = None):
    cookie_path = cookie_path or default_cookie_path
    os.makedirs(os.path.dirname(cookie_path), exist_ok=True)
    session.cookies.save()
    logging.info("Saved session into {}".format(os.path.abspath(cookie_path)))
    os.chmod(cookie_path, 0o600)


def load_cookie_to(session: requests.Session, cookie_path: Optional[str] = None):
    cookie_path = cookie_path or default_cookie_path
    session.cookies = LWPCookieJar(cookie_path)
    if os.path.exists(cookie_path):
        session.cookies.load()
コード例 #2
0
import json
import os
import time

import requests
from atcodertools.release_management.version import __version__
from atcodertools.fileutils.artifacts_cache import get_cache_file_path


class VersionCheckError(Exception):
    pass


cache_file_path = get_cache_file_path('version_cache.txt')

HOUR_IN_SEC = 60 * 60


def _fetch_latest_version():
    dic = json.loads(
        requests.get("https://pypi.org/pypi/atcoder-tools/json").text)
    return dic["info"]["version"]


def _get_latest_version_cache():
    if not os.path.exists(cache_file_path):
        return None
    with open(cache_file_path, 'r') as f:
        info = f.read().split()
        version, timestamp_sec = info[:2]
コード例 #3
0
import requests
from bs4 import BeautifulSoup

from atcodertools.client.models.submission import Submission
from atcodertools.common.language import Language
from atcodertools.fileutils.artifacts_cache import get_cache_file_path
from atcodertools.client.models.contest import Contest
from atcodertools.client.models.problem import Problem
from atcodertools.client.models.problem_content import ProblemContent, InputFormatDetectionError, SampleDetectionError


class LoginError(Exception):
    pass


default_cookie_path = get_cache_file_path('cookie.txt')


def save_cookie(session: requests.Session, cookie_path: Optional[str] = None):
    cookie_path = cookie_path or default_cookie_path
    os.makedirs(os.path.dirname(cookie_path), exist_ok=True)
    session.cookies.save()
    logging.info("Saved session into {}".format(os.path.abspath(cookie_path)))
    os.chmod(cookie_path, 0o600)


def load_cookie_to(session: requests.Session,
                   cookie_path: Optional[str] = None):
    cookie_path = cookie_path or default_cookie_path
    session.cookies = LWPCookieJar(cookie_path)
    if os.path.exists(cookie_path):
コード例 #4
0
import json
import os
import time

import requests
from atcodertools.release_management.version import __version__
from atcodertools.fileutils.artifacts_cache import get_cache_file_path


class VersionCheckError(Exception):
    pass


cache_file_path = get_cache_file_path('version_cache.txt')

HOUR_IN_SEC = 60 * 60


def _fetch_latest_version():
    dic = json.loads(requests.get(
        "https://pypi.org/pypi/atcoder-tools/json").text)
    return dic["info"]["version"]


def _get_latest_version_cache():
    if not os.path.exists(cache_file_path):
        return None
    with open(cache_file_path, 'r') as f:
        info = f.read().split()
        version, timestamp_sec = info[:2]