This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def samogon_cook(self): | |
sam_base_formula = [1.0, 0.1, 0.2, 3.0] | |
if 0.0 in self.res: | |
print "Ошибка, нехватает компонетов" | |
return self.sam_info() | |
sam_calc = min(map(lambda x, y: y/x, sam_base_formula, self.res)) | |
self.res = map(lambda x, y: (y - x*sam_calc), sam_base_formula, self.res) | |
print "Варка самогона..." | |
time.sleep(sam_calc) | |
return "Сварено: %.2f л" % sam_calc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
class Node: | |
def __init__(self, name, children=None): | |
self.children = children or list() | |
self.name = name | |
self.system = set() | |
def dependOn(self, node): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
class Node: | |
def __init__(self, name, children=None): | |
self.children = children or list() | |
self.name = name | |
def dependOn(self, node): | |
self.children.append(node) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
class Node: | |
def __init__(self,data=None,yes=None,no=None): | |
self.data = data | |
self.yes = yes | |
self.no = no | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Отправка почты по протоколу SMTP | |
""" | |
import smtplib | |
def prompt(prompt): | |
return raw_input(prompt).strip() | |
fromaddr = prompt("From: ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Запрос к серверу, чтение заголовков ответа | |
""" | |
import sys, urllib2 | |
req = urllib2.Request(sys.argv[1]) | |
try: | |
fd = urllib2.urlopen(req) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Получение списка файлов | |
""" | |
from ftplib import FTP | |
ftp = FTP('ftp.cwi.nl') # connect to host, default port | |
ftp.login() # user anonymous, passwd anonymous@ | |
ftp.retrlines('LIST') # list directory contents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Получение списка файлов в домашнем каталоге | |
""" | |
import getpass | |
import sys | |
import telnetlib | |
HOST = "localhost" | |
user = raw_input("Enter your remote account: ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Обратный DNS клиент | |
""" | |
import sys, socket | |
try: | |
result = socket.gethostbyaddr("66.249.71.15") | |
print "Primary hostname:" | |
print " " + result[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Файловая база данных sqlite3 | |
""" | |
conn = sqlite3.connect('/tmp/example') | |
c = conn.cursor() | |
# Create table |