# Path: skier/pgp.py
# def add_pgp_key(armored: str) -> tuple:
# def get_pgp_armor_key(keyid: str) -> str:
# def get_pgp_keyinfo(keyid: str) -> keyinfo.KeyInfo:
# def search_through_keys(search_str: str, page: int=1, count: int=10) -> Pagination:
# 
# Path: cfg.py
# API_VERSION = 1
# 
# SKIER_VERSION = 1.5


import datetime
import threading
import requests
import db
import cfg
from skier import pgp
from cfg import API_VERSION, SKIER_VERSION




def import_key(keyserver: str, keyid: str):
    """
    Attempts to import a key from the keyserver.
    :param keyserver: The keyserver to import from.
    :param keyid: The Key ID to import.
    :return:
        One of many codes:
        - 0: Success
        - -1: key not found
        - -2: Could not connect to keyserver
        - -3: Invalid key
        - -4: Already exists on server unchanged
    """
    # Check to see if the server is a skier server.
    is_skier = False
    try:
        if 'http://' not in keyserver and "https://" not in keyserver:
            keyserver = "http://" + keyserver
        r = requests.post(keyserver + "/skier", data=[API_VERSION,SKIER_VERSION])
        if r.status_code == 200:
            js = r.json()
            # Check the API version to make sure we're compatible.

# Path: skier/pgp.py
# def add_pgp_key(armored: str) -> tuple:
# def get_pgp_armor_key(keyid: str) -> str:
# def get_pgp_keyinfo(keyid: str) -> keyinfo.KeyInfo:
# def search_through_keys(search_str: str, page: int=1, count: int=10) -> Pagination:
# 
# Path: cfg.py
# API_VERSION = 1
# 
# SKIER_VERSION = 1.5


# Path: skier/pgpactions.py
import datetime
import threading
import requests
import db
import cfg
from skier import pgp
from cfg import API_VERSION, SKIER_VERSION





def import_key(keyserver: str, keyid: str):
    """
    Attempts to import a key from the keyserver.
    :param keyserver: The keyserver to import from.
    :param keyid: The Key ID to import.
    :return:
        One of many codes:
        - 0: Success
        - -1: key not found
        - -2: Could not connect to keyserver
        - -3: Invalid key
        - -4: Already exists on server unchanged
    """
    # Check to see if the server is a skier server.
    is_skier = False
    try:
        if 'http://' not in keyserver and "https://" not in keyserver:
            keyserver = "http://" + keyserver
        r = requests.post(keyserver + "/skier", data=[API_VERSION,SKIER_VERSION])
        if r.status_code == 200:
            js = r.json()
            # Check the API version to make sure we're compatible.

            if js['api_version'] == API_VERSION: