Пример #1
0
def launch():
    if osdetect() == "Windows":
        go = system('py.exe "PythonOS.py"')
    else:
        go = system('python3 "PythonOS.py"')
    if go == 1:
        print("\n\nAn error has occurred in PythonOS. Press enter to restart.")
        input("")
    checkfile()
    if not path.exists("PythonOS.py") and not path.exists("cmd.exe"):
        print("\n\nPythonOS executable is missing. Please reinstall PythonOS.")
        print("\n\nPress any key to restart.")
        input()
        remove("lock")
        go = 0
    if go == 2:
        print(
            "\n\nUnable to start the virtual machine. Are you trying to run\nthe VM from a network location?\n\nPress enter to exit."
        )
        input("")
        remove("lock")
        exit()
Пример #2
0
from os import system, path, remove
from platform import system as osdetect
from sys import stdout
from time import sleep
global go

try:
    from playsound import playsound
except:
    if osdetect() == "Darwin":
        print("Missing dependancy detected: pyobjc")
        print(
            "To continue with an error free use of PythonOS, you\nneed to install pyobjc."
        )
        if input("Would you like me to do that for you? [Y/n] : ") == "n":
            print("Installation denied, closing PythonOS.")
            exit()
        else:
            try:
                print(
                    "Running command: sudo pip3 install -U pyobjc\nPlease enter your password when prompted."
                )
                system('sudo pip3 install -U pyobjc')
                print("Setup complete, continuing startup.")
            except:
                print("Hm, something went wrong while installing Pyobjc.")
                input(
                    "Press enter to close PythonOS.\nYou will need to install pyobjc manually."
                )
                exit()
Пример #3
0
def main():
    global DEBUG, CONFIG, HISTORY_FILE
    config = get_config_data(CONFIG)
    DEBUG = config['debug']
    # regex_param = re.IGNORECASE|re.UNICODE|re.DOTALL
    regex_param = re.UNICODE | re.DOTALL
    prepare_func = lambda x: parse.urlencode(x, encoding="utf-8")
    # base dicts
    urls = {
        "base":
        "http://zakupki.gov.ru/pgz/public/action/search/simple/result?",
        "xml":
        "http://zakupki.gov.ru/pgz/printForm?type=NOTIFICATION&id=",
        "common":
        "http://zakupki.gov.ru/pgz/public/action/orders/info/common_info/show?notificationId=",
        "protocol":
        "http://zakupki.gov.ru/pgz/public/action/orders/info/commission_work_result/show?notificationId=",
        'searchwin':
        "http://www.etp-micex.ru/organisation/catalog/supplier/fullTitle/{#filltext#}/organisationTypeId/0/",
    }
    regexps = {
        'get_base_page':
        re.compile(r"showNotificationPrintForm\(\d+\);return false;",
                   regex_param),
        'get_ids':
        re.compile(r".*?id=(\d+)$", regex_param),
        'get_date1':
        re.compile(r"^redirectToAE", regex_param),
        'get_date2':
        re.compile(
            r"Протокол подведения итогов аукциона.*?\s+от\s+(\d{2}\.\d{2}\.\d{4})",
            regex_param),
        'get_winner':
        re.compile(r"iceDatTblRow\d+", regex_param),
        'max_sum':
        re.compile(r"<maxPriceXml>(.{1,99})</maxPriceXml>", regex_param),
        'garant':
        re.compile(
            r"<guaranteeApp>.*?<amount>(.{1,99})</amount>.*?</guaranteeApp>",
            regex_param),
        # 'garant': re.compile(r"<guaranteeContract>.*?<amount>(.{1,99})</amount>.*?</guaranteeContract>",regex_param),
    }
    params = {
        'orderName': '',
        '_orderNameMorphology': 'on',
        '_orderNameStrict': 'on',
        'placingWayType': 'EF',
        '_placementStages': 'on',
        '_placementStages': 'on',
        'placementStages': 'FO',
        '_placementStages': 'on',
        '_placementStages': 'on',
        'initiatorFullName': '',
        'initiatorId': '',
        'priceRange': 'H',
        'currencyCode': 'RUB',
        '_smallBisnes': 'on',
        'index': 1,
        'sortField': 'lastEventDate',
        'descending': 'true',
        'tabName': 'FO',
        'lotView': 'false',
        'pageX': '',
        'pageY': ''
    }
    # NOTE: encoding - optional for this case
    params['priceRange'] = config['category']
    if DEBUG:
        prepate_url = prepare_func(params)
        print('create url: ' + urls['base'] + prepate_url)
    # (create) and open DATABASE
    connect = get_connection(HISTORY_FILE)
    companies = []
    try:
        pageCount, recordCount, page = 0, 0, config['first']
        time_start = time.time()
        print('Start program')
        while (page <= config['last']):
            params['index'] = page
            prepate_url = prepare_func(params)
            from_url = getURLcontent(urls['base'] + prepate_url)
            if from_url:
                ids_str = parser_main_page(regexps['get_ids'],
                                           regexps['get_base_page'], from_url)
                if not ids_str:
                    print("Error in page {}".format(page))
                    continue
                for i in ids_str:
                    # if i in DB, call continue (data in history)
                    if check_history(connect, i):
                        print("record {0} already in history".format(i))
                        continue
                    print("do record number {0}...".format(i))
                    istr = str(i)
                    ones = Zakupki(i, urls['common'], DEBUG)
                    # read protocol page, find date
                    protocol_page = ones.get_date(urls['protocol'] + istr,
                                                  regexps['get_date1'],
                                                  regexps['get_date2'])
                    if ones.necessary_date(config['start'], config['end']):
                        # get winner
                        onesexist = ones.get_winner(protocol_page,
                                                    regexps['get_winner'])
                        if onesexist:
                            # get sums
                            ones.get_sums_common(urls['common'] + istr)
                            if ones.garantsum > 0:
                                ones.get_win_data(urls['searchwin'],
                                                  request.pathname2url)
                                # add new record
                                companies.append(ones)
                            elif DEBUG:
                                print("GarantSum=0")
            else:
                print(
                    "Error getURL or not found data no page={0}".format(page))
            page += 1
        if companies:
            # save to history
            saves = saveInHistory(connect, companies)
            # print result
            print_from_db(saves)
            print(
                "Finish program, found {0} record(s), save to file {2} ones, for {1} second(s)"
                .format(len(companies), round(time.time() - time_start, 2),
                        len(saves)))
        else:
            print("Work time {0} second(s)".format(
                round(time.time() - time_start, 2)))
            print("!!!   Program did not found data   !!!")
        connect.close()
        if osdetect() == 'Windows':
            input("Press any key for close window....")
    except (ValueError, IndexError) as e:
        print("Error: {0}".format(e))
Пример #4
0
def screenclear():
    if osdetect() == "Windows":
        system('cls')
    else:
        system('clear')
Пример #5
0
from time import sleep
from random import randint
from platform import system as osdetect
if osdetect() == "Windows":
    from winsound import Beep as beep
else:

    def beep(thinga, thingb):
        print("", end='\r')


rd = randint(1, 100)
print("PhoenixBIOS 4.0 Release 6.0"), sleep(0.05)
print("Copyright 1985-2001 Phoenix Technologies Ltd."), sleep(0.05)
print("All Rights Reserved"), sleep(0.05)
print("Copyright 2016 RotoWare"), sleep(0.05)
print("PythonBIOS build 034\n"), sleep(0.5)
print("640K System RAM Passed"), sleep(1)
if not rd == 57:
    for a in range(0, 129):
        print(str(a + a + a + a) + "M Extended RAM Passed",
              end='\r'), sleep(0.001)
else:
    for a in range(0, 257):
        print(str(a + a) + "M Extended RAM Passed", end='\r'), sleep(0.001)
    sleep(2)
    for a in range(0, 513):
        print(str(a) + "M Extended RAM Passed", end='\r'), sleep(0.001)
print(""), sleep(1)
print("Scanning IDE/SATA channels for devices...", end='\r'), sleep(2)
print("Fixed Disk 0: RotoWare SATA Virtual Hard Drive"), sleep(0.1)
Пример #6
0
def wintitle():
    if osdetect() == "Windows":
        system('title PythonOS VM - Version ' + version + ' (C) RotoWare ' + year) # This sets the command line window title.
    else:
        stdout.write('\x1b]2;' + 'PythonOS VM - Version ' + version + ' (C) RotoWare ' + year + '\x07')
Пример #7
0
def main():
    global DEBUG, CONFIG, HISTORY_FILE
    config = get_config_data(CONFIG)
    DEBUG = config['debug']
    # regex_param = re.IGNORECASE|re.UNICODE|re.DOTALL
    regex_param = re.UNICODE|re.DOTALL
    prepare_func = lambda x: parse.urlencode(x, encoding="utf-8")
    # base dicts
    urls = {"base": "http://zakupki.gov.ru/pgz/public/action/search/simple/result?",
        "xml": "http://zakupki.gov.ru/pgz/printForm?type=NOTIFICATION&id=",
        "common": "http://zakupki.gov.ru/pgz/public/action/orders/info/common_info/show?notificationId=",
        "protocol": "http://zakupki.gov.ru/pgz/public/action/orders/info/commission_work_result/show?notificationId=",
        'searchwin': "http://www.etp-micex.ru/organisation/catalog/supplier/fullTitle/{#filltext#}/organisationTypeId/0/",
    }
    regexps = {
        'get_base_page': re.compile(r"showNotificationPrintForm\(\d+\);return false;",regex_param),
        'get_ids': re.compile(r".*?id=(\d+)$", regex_param),
        'get_date1': re.compile(r"^redirectToAE", regex_param),
        'get_date2': re.compile(r"Протокол подведения итогов аукциона.*?\s+от\s+(\d{2}\.\d{2}\.\d{4})", regex_param),
        'get_winner': re.compile(r"iceDatTblRow\d+", regex_param),
        'max_sum': re.compile(r"<maxPriceXml>(.{1,99})</maxPriceXml>",regex_param),
        'garant': re.compile(r"<guaranteeApp>.*?<amount>(.{1,99})</amount>.*?</guaranteeApp>",regex_param),
        # 'garant': re.compile(r"<guaranteeContract>.*?<amount>(.{1,99})</amount>.*?</guaranteeContract>",regex_param),
    }
    params = {'orderName': '', '_orderNameMorphology': 'on', '_orderNameStrict': 'on', 'placingWayType': 'EF', 
        '_placementStages': 'on', '_placementStages': 'on', 
        'placementStages': 'FO', '_placementStages': 'on', '_placementStages': 'on',
        'initiatorFullName': '', 'initiatorId': '', 'priceRange': 'H', 'currencyCode': 'RUB', '_smallBisnes': 'on',
        'index': 1, 'sortField': 'lastEventDate', 'descending': 'true', 'tabName': 'FO', 'lotView': 'false', 
        'pageX': '', 'pageY': ''
    }
    # NOTE: encoding - optional for this case
    params['priceRange'] = config['category']
    if DEBUG:
        prepate_url = prepare_func(params)
        print('create url: ' + urls['base'] + prepate_url)
    # (create) and open DATABASE
    connect = get_connection(HISTORY_FILE)
    companies = []
    try:
        pageCount, recordCount, page = 0, 0, config['first']
        time_start = time.time()
        print('Start program')
        while (page <= config['last']):
            params['index'] = page
            prepate_url = prepare_func(params)
            from_url = getURLcontent(urls['base'] + prepate_url)
            if from_url:
                ids_str = parser_main_page(regexps['get_ids'], regexps['get_base_page'], from_url)
                if not ids_str:
                    print("Error in page {}".format(page))
                    continue
                for i in ids_str:
                    # if i in DB, call continue (data in history)
                    if check_history(connect, i):
                        print("record {0} already in history".format(i))
                        continue
                    print("do record number {0}...".format(i))
                    istr = str(i)
                    ones = Zakupki(i, urls['common'], DEBUG)
                    # read protocol page, find date
                    protocol_page = ones.get_date(urls['protocol'] + istr,regexps['get_date1'], regexps['get_date2'])
                    if ones.necessary_date(config['start'], config['end']):
                        # get winner
                        onesexist = ones.get_winner(protocol_page, regexps['get_winner'])
                        if onesexist:
                            # get sums
                            ones.get_sums_common(urls['common'] + istr)
                            if ones.garantsum > 0:
                                ones.get_win_data(urls['searchwin'], request.pathname2url)
                                # add new record
                                companies.append(ones)
                            elif DEBUG:
                                print("GarantSum=0")
            else:
                print("Error getURL or not found data no page={0}".format(page))
            page += 1
        if companies:
            # save to history
            saves = saveInHistory(connect, companies)
            # print result
            print_from_db(saves)
            print("Finish program, found {0} record(s), save to file {2} ones, for {1} second(s)".format(len(companies), round(time.time() - time_start,2), len(saves)))
        else:
            print("Work time {0} second(s)".format(round(time.time() - time_start,2)))
            print("!!!   Program did not found data   !!!")
        connect.close()
        if osdetect() == 'Windows':
            input("Press any key for close window....")
    except (ValueError, IndexError) as e:
        print("Error: {0}".format(e))