Beispiel #1
0
def get_data_for_creating_array():
    size = int(raw_input("Please, input size of array: "))
    while size < 1:
        size = int(raw_input("size should be more than 0: "))
    min_val = math.fabs(int(raw_input("Please, min value in array: ")))
    max_val = math.fabs(int(raw_input("Please, max value in array: ")))

    return size, min(min_val, max_val), max(min_val, max_val)
def send():
    client = socket(AF_INET, SOCK_STREAM)
    connected = False
    while not connected:
        try:
            client.connect(ADDRESSClient)
            connected = True
        except ConnectionRefusedError:
            pass
    while True:
        try:
            text = str(raw_input('i> ')).replace("\n", "")
            client.send(text.encode('utf_8'))
        except ConnectionResetError:
            break
    client.close()
__author__ = 'KOL'

from Tools.Scripts.ftpmirror import raw_input
import re


def get_type(string):
    matcher = re.compile(r"<type '[a-z_]+'>")
    if matcher.match(string):
        matcher = re.compile(r"'[a-z_]+'")
        return matcher.findall(string)
    else:
        return None

while True:
    testText = raw_input("Please, input string: ")
    print(get_type(testText))


__author__ = 'KOL'

from Tools.Scripts.ftpmirror import raw_input
import re


matcher = re.compile(r"\b[bh][aiu]t\b")
while True:
    testText = raw_input("Please, input one word: ")
    result = matcher.findall(testText)
    if len(result) != 0:
        print("matched")
        print(result)
    else:
        print("not matched")
from socket import *
from Tools.Scripts.ftpmirror import raw_input

HOST = str(raw_input("Please, input hostName:")).replace("\n", "")
PORT = str(raw_input("Please, input port:")).replace("\n", "")

if not HOST:
    HOST = "localhost"
if not PORT:
    PORT = 21567
else:
    PORT = int(PORT)

BUFFER_SIZE = 1024
ADDRESS = (HOST, PORT)

udpCliSock = socket(AF_INET, SOCK_DGRAM)

while True:
    data = raw_input('> ')
    if not data:
        break
    udpCliSock.sendto(data.encode('utf-8'), ADDRESS)
    data, ADDRESS = udpCliSock.recvfrom(BUFFER_SIZE)
    if not data:
        break
    print(data.decode("utf_8"))

udpCliSock.close()
    findall = matcher.findall(html)
    if len(findall) != 0:
        title = findall[0].replace('<span id="btAsinTitle"  >', "").replace("<span", "")
    else:
        title = None

    matcher = re.compile(r'<b class="priceLarge">\$\d+\.?(?:\d+|)</b>|<span class="rentPrice">\$\d+\.?(?:\d+|)</span>')
    findall = matcher.findall(html)
    if len(findall) != 0:
        price = findall[0].replace('<b class="priceLarge">', "").replace('</b>', "").\
            replace('<span class="rentPrice">', "").replace("</span>", "")
    else:
        price = None

    matcher = re.compile(r'<span class="availGreen">[\.a-zA-Z 0-9-_]+</span>')
    findall = matcher.findall(html)
    if len(findall) != 0:
        status = findall[0].replace('<span class="availGreen">', "").replace('.</span>', "")
    else:
        status = None
    return title, price, status

#0132269937
#0672329786
#1449355730
#193518220X
while True:
    isbn = raw_input("Please, input ISBN of book on Amazon.com: ")
    title, price, status = get_simple_info_about_book_from_amazon("http://www.amazon.com/dp/" + isbn)
    print(title, price, status)
__author__ = 'KOL'

import threading
from socket import *
from Tools.Scripts.ftpmirror import raw_input

BUFFER_SIZE = 1024

HOSTServer = ''
PORTServer = str(raw_input("Please, input port of server(somebody):")).replace("\n", "")
if not PORTServer:
    PORTServer = 12345
else:
    PORTServer = int(PORTServer)
HOSTClient = "192.168.0.101"
PORTClient = str(raw_input("Please, input port of client(you):")).replace("\n", "")
if not PORTServer:
    PORTClient = 12346
else:
    PORTClient = int(PORTClient)
ADDRESSServer = (HOSTServer, PORTServer)
ADDRESSClient = (HOSTClient, PORTClient)


def send():
    client = socket(AF_INET, SOCK_STREAM)
    connected = False
    while not connected:
        try:
            client.connect(ADDRESSClient)
            connected = True
ADDRESSClient = (HOSTClient, PORTClient)

BUFFER_SIZE = 1024

server = socket(AF_INET, SOCK_STREAM)
server.bind(ADDRESSServer)
server.listen(100)

client = socket(AF_INET, SOCK_STREAM)
connected = False
while not connected:
    try:
        client.connect(ADDRESSClient)
        connected = True
    except ConnectionRefusedError:
        pass

tcpCliSock, address = server.accept()
while True:
    try:
        data = str(raw_input('i> ')).replace("\n", "")
        client.send(data.encode('utf_8'))

        data = tcpCliSock.recv(BUFFER_SIZE)
        print("somebody>" + data.decode("utf_8"))
    except ConnectionResetError:
        break

tcpCliSock.close()
client.close()
server.close()
Beispiel #9
0
# -*- encoding: utf-8 -*-
from itertools import permutations, cycle
from Tools.Scripts.ftpmirror import raw_input
import re

__author__ = 'pahaz'

if __name__ == "__main__":
    while True:
        puzzle = raw_input("puzzle> ")
        puzzle = re.sub(r'\s', '', puzzle).replace('=', '==')
        if not puzzle: break

        variables = set(puzzle) - set("=-+*")
        invalid_replaces_for_zero = set(re.findall(r'\b(\w)', puzzle))

        is_solved = False
        for permutation in permutations(map(str, range(10)), len(variables)):
            test_puzzle = puzzle
            has_invalid_replaces = False
            for v, n in zip(variables, permutation):
                if n == '0' and v in invalid_replaces_for_zero:
                    has_invalid_replaces = True
                    break
                test_puzzle = test_puzzle.replace(v, n)

            if not has_invalid_replaces and eval(test_puzzle):
                is_solved = True
                print(puzzle, 'is', test_puzzle)

        if not is_solved:
__author__ = 'KOL'

from socket import *
from Tools.Scripts.ftpmirror import raw_input

BUFFER_SIZE = 102400

s = socket(AF_INET, SOCK_STREAM)
while True:
    try:
        link = str(raw_input("Please, input hostName http://")).replace("\n", "")
        file = open("Exercise11/ex11.html", "w")

        s.connect((link, 80))

        s.sendall(("GET http://" + link + " HTTP/1.0\n\n").encode('utf_8'))
        data = s.recv(BUFFER_SIZE)
        file.write(data.decode("cp1251"))
        file.close()
        break
    except error:
        print("Wrong link. Try again later :)")
        continue

s.close()