def __init__(self, ip=None, port=None):
   # self.config = config.get()
   self.ip = ip or IP
   # self.ip = ip or ('server_ip' in self.config['server_ip'] or IP)
   self.port = port or PORT
   # self.port = port or ('server_port' in self.config['server_port'] or PORT)
   self.greeter = Greeter()
   self.greeter.set_output_methods('voice|print')
Example #2
0
def main():
    if len(sys.argv) > 1:
        name = sys.argv[1]
    else:
        name = "world"

    gr = Greeter(name)
    gr.greet()
    def test_greet_notString_raises(self):
        greeter = Greeter()

        try:
            greeting = greeter.greet(10)
        except TypeError as e:
            return

        self.fail("No exception thrown")
class Detector:
  headers = {
    'form': {
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    }
  }
  threading_enabled = False

  confidence_threshold = 4000

  def __init__(self, ip=None, port=None):
    # self.config = config.get()
    self.ip = ip or IP
    # self.ip = ip or ('server_ip' in self.config['server_ip'] or IP)
    self.port = port or PORT
    # self.port = port or ('server_port' in self.config['server_port'] or PORT)
    self.greeter = Greeter()
    self.greeter.set_output_methods('voice|print')


  def set_threading_enabled(self, value):
    self.threading_enabled = value


  def detect_image(self, image_data):
    if self.threading_enabled:
      t = threading.Thread(target=self.send_request, args=(image_data,))
      t.start()
    else:
      self.send_request(image_data)


  def send_request(self, image_data):
    params = {
      '': base64.b64encode(image_data)
    }
    headers = self.headers['form']

    try:
      conn = httplib.HTTPConnection(self.ip, self.port)
      conn.request('POST', '/api/face/detect', urllib.urlencode(params), headers)
      self.handle_response(conn.getresponse())
      conn.close()
    except:
      print 'connection to server failed'


  def handle_response(self, response):
    if response.status != 200 or response.reason != 'OK':
      print 'Error in response from server', response.status, response.reason
      # print response.read()
      return

    faces = json.loads(response.read())

    self.greeter.greet_faces(faces)
Example #5
0
    def __init__(self):
        self.API_TOKEN = "1700885261:AAETCokNpqNDk44x3d5XASfnQfzxiNOKWfI"  ## os.environ["SECRET"]
        self.contatinhosSheet = "http://bit.ly/contatosbcc021"
        self.githubRepo = "https://github.com/lineuzinho-icmc/lineuzinho"
        self.usefulLinks = "Estamos adicionando todo mundo aos poucos. Se puder ajudar a achar o pessoal, passa o link do grupo na descrição!\n\nInscrição na semana de recepção: calouros.icmc.usp.br/\n\nGuia do Bixo: https://bit.ly/3c9mcUG\n\nContatinho de geral: {0}\n\n".format(
            self.contatinhosSheet)
        self.docsChannel = "https://t.me/docs21"

        self.greeter = Greeter()
        self.forwarder = Forwarder()
        self.beaner = Beaner()
Example #6
0
    def __init__(self):
        self.API_TOKEN = os.environ["SECRET"]
        self.contatinhosSheet = "http://bit.ly/contatosbcc021"
        self.githubRepo = "https://github.com/lineuzinho-icmc/lineuzinho"
        self.usefulLinks = "Estamos adicionando todo mundo aos poucos. Se puder ajudar a achar o pessoal, passa o link do grupo na descrição!\n\nInscrição na semana de recepção: calouros.icmc.usp.br/\n\nGuia do Bixo: https://bit.ly/3c9mcUG\n\nContatinho de geral: {0}\n\nEnquetes: https://t.me/joinchat/qrJ_MrnHDbE1ZmNh\n\n".format(
            self.contatinhosSheet)
        self.docsChannel = "https://t.me/docs21"

        self.greeter = Greeter()
        self.forwarder = Forwarder()
        self.beaner = Beaner()

        self.conn = Connection()
        self.last_pi_call = time.time()
Example #7
0
class Lineuzinho:
    def __init__(self):
        self.API_TOKEN = "1700885261:AAETCokNpqNDk44x3d5XASfnQfzxiNOKWfI"  ## os.environ["SECRET"]
        self.contatinhosSheet = "http://bit.ly/contatosbcc021"
        self.githubRepo = "https://github.com/lineuzinho-icmc/lineuzinho"
        self.usefulLinks = "Estamos adicionando todo mundo aos poucos. Se puder ajudar a achar o pessoal, passa o link do grupo na descrição!\n\nInscrição na semana de recepção: calouros.icmc.usp.br/\n\nGuia do Bixo: https://bit.ly/3c9mcUG\n\nContatinho de geral: {0}\n\n".format(
            self.contatinhosSheet)
        self.docsChannel = "https://t.me/docs21"

        self.greeter = Greeter()
        self.forwarder = Forwarder()
        self.beaner = Beaner()

    def start(self, update, context):
        update.message.reply_text("pó fala meu rei")

    def greet(self, update, context):
        newMembers = update.message.new_chat_members
        greetings = self.greeter.generateNewMembersGreetings(newMembers)
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=greetings)

    def links(self, update, context):
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=self.usefulLinks,
                                 disable_web_page_preview=True)

    def getRepo(self, update, context):
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=self.githubRepo)

    def getContatinhos(self, update, context):
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text="CHAMA NOS CONTATINHO\n{0}".format(
                                     self.contatinhosSheet),
                                 disable_web_page_preview=True)

    def getDocsChannel(self, update, context):
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=self.docsChannel)

    def save(self, update, context):
        self.forwarder.saveToDocs(update, context)

    def getBeanFlavor(self, update, context):
        beanFlavor = self.beaner.getFlavor()
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=beanFlavor)

    def help(self, update, context):
        update.message.reply_text(
            "digita \"/\" no teclado pra dar uma olhada nos comandos disponíveis :V"
        )
Example #8
0
 def test_greet(self, mock_time):
     mock_time.now.return_value.hour = 20
     self.assertEqual(Greeter.greet("Ivan"), "Добрый вечер Ivan")
Example #9
0
class Lineuzinho:
    def __init__(self):
        self.API_TOKEN = os.environ["SECRET"]
        self.contatinhosSheet = "http://bit.ly/contatosbcc021"
        self.githubRepo = "https://github.com/lineuzinho-icmc/lineuzinho"
        self.usefulLinks = "Estamos adicionando todo mundo aos poucos. Se puder ajudar a achar o pessoal, passa o link do grupo na descrição!\n\nInscrição na semana de recepção: calouros.icmc.usp.br/\n\nGuia do Bixo: https://bit.ly/3c9mcUG\n\nContatinho de geral: {0}\n\nEnquetes: https://t.me/joinchat/qrJ_MrnHDbE1ZmNh\n\n".format(
            self.contatinhosSheet)
        self.docsChannel = "https://t.me/docs21"

        self.greeter = Greeter()
        self.forwarder = Forwarder()
        self.beaner = Beaner()

        self.conn = Connection()
        self.last_pi_call = time.time()

    def start(self, update, context):
        update.message.reply_text("pó fala meu rei")

    def greet(self, update, context):
        newMembers = update.message.new_chat_members
        greetings = self.greeter.generateNewMembersGreetings(newMembers)
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=greetings)

    def links(self, update, context):
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=self.usefulLinks,
                                 disable_web_page_preview=True)

    def getRepo(self, update, context):
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=self.githubRepo)

    def getContatinhos(self, update, context):
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text="CHAMA NOS CONTATINHO\n{0}".format(
                                     self.contatinhosSheet),
                                 disable_web_page_preview=True)

    def getDocsChannel(self, update, context):
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=self.docsChannel)

    def save(self, update, context):
        self.forwarder.saveToDocs(update, context)

    def getBeanFlavor(self, update, context):
        beanFlavor = self.beaner.getFlavor()
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=beanFlavor)

    def getPiRanking(self, update, context):
        if time.time() - self.last_pi_call > 86400:
            self.last_pi_call = time.time()
            pi_manager.generate_daily_ranking()
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=pi_manager.get_daily_ranking())

    def getUserPiRanking(self, update, context):
        if time.time() - self.last_pi_call > 86400:
            self.last_pi_call = time.time()
            pi_manager.generate_daily_ranking()
        context.bot.send_message(chat_id=update.effective_chat.id,
                                 text=pi_manager.get_member_ranking(
                                     update.message.from_user.username))

    def help(self, update, context):
        update.message.reply_text(
            "digita \"/\" no teclado pra dar uma olhada nos comandos disponíveis :V"
        )

    def randomActivityAlert(self, update, context):
        if random.randint(0, 500) == 250:
            update.message.reply_text(
                "Oi, desculpa atrapalhar, mas... já fez suas atividades de hoje? :)"
            )
Example #10
0
from greeter import Greeter
from insult_comic import Insult_Comic


if __name__ == '__main__':
    gr = Greeter()
    ic = Insult_Comic()
    gr.speak("Amar")
    ic.speak("Amar")
Example #11
0
import sys
from greeter import Greeter

# Try/Except for argv/c

try:
	name = sys.argv[1]
except IndexError, NameError:
	print "Usage: python something_useful.py <name>"
	name = 'World'


greeter = Greeter(name)
# Prints name

print greeter.greet()




 def test_evn(self, mock_datetime):
     mock_datetime.datetime.now.return_value.hour = 18
     result = Greeter().greet("Varya")
     self.assertEqual(result, "Добрый вечер Varya")
Example #13
0
def main():
    cordial = Greeter()
    roast = InsultComic()
    cordial.speak()
    roast.speak()
Example #14
0
import os
import time

from greeter import Greeter
from character_creator import CharacterCreator
from character import Character
import util

if __name__ == '__main__':
    os.system('clear')
    greeter = Greeter("Hello, resident of Panem. Do you want to play a game? ")
    if greeter.greet():
        print("Ok, next time!")
    else:
        creator = CharacterCreator()
        choose_player = input(
            "Great! \nPress 1 to create a custom player.\nPress 2 to randomly generate a player.\n"
        )
        if choose_player == "1":
            player_character = creator.make_custom_character()
        else:
            player_character = creator.generate_random_character()

        os.system('clear')
        player_character.display()
        input("Press Enter to continue: ")
        os.system('clear')

        if player_character.district == 1 or player_character.district == 2 or player_character.district == 4:
            career = "lunge forward to volunteer."
        else:
Example #15
0
 def test_good_night(self, mock_time):
     mock_time.now.return_value.hour = 23
     self.assertEqual(Greeter.greet("Ivan"), "Доброй ночи Ivan")
Example #16
0
# Author: Nadav Luzzato ([email protected])
import sys
from greeter import Greeter
name = "World"
# Comment for git
if (len(sys.argv) > 1):
	name = str(sys.argv[1])
greeter = Greeter(name)
greeter.greet()
 def test_greeterTest(self):
     greeter = Greeter()
     greeting = greeter.greet("Juraj")
     self.assertEqual(greeting, "Hello, Juraj")
 def test_greet(self, mock_datetime):
     mock_datetime.datetime.now.return_value.hour = 12
     result = Greeter().greet("Varya")
     self.assertEqual(result, "Привет Varya")
 def test_log(self, mock_logging):
     Greeter().greet("Varya")
     mock_logging.info.assert_called_with("Informational message")
 def test_nigth(self, mock_datetime):
     mock_datetime.datetime.now.return_value.hour = 4
     result = Greeter().greet("Varya")
     self.assertEqual(result, "Доброй ночи Varya")
Example #21
0
def greeter():
    # setup code
    g = Greeter()

    # pass the result to the test
    yield g
Example #22
0
def test_should_say_hello():
    greeter = Greeter("John Doe")
    greeting = greeter.say_hello()
    assert greeting == "Hello, John Doe!"
Example #23
0
 def test_logging_greet(self, mock_logger):
     name = Greeter.greet("Ivan")
     mock_logger.info.assert_called_with('You greeting with Ivan')
Example #24
0
from greeter import Greeter
from insult_comic import InsultComic

neww = Greeter()
insult = InsultComic()

insult.speak("E")
neww.speak("ELLIOT")
Example #25
0
def main():
    greeter = Greeter()
    insult = Insult()

    greeter.speak("Wesley")
    insult.speak("Wesley")
 def test_morn(self, mock_datetime):
     mock_datetime.datetime.now.return_value.hour = 8
     result = Greeter().greet("Varya")
     self.assertEqual(result, "Доброе утро Varya")
Example #27
0
def main():
    g = Greeter()
    i = InsultComic()
    g.speak('Wesley')
    i.speak('Wesley')
Example #28
0
from greeter import Greeter
from insult_comic import Insult

if __name__ == "__main__":
    gr = Greeter()
    ins = Insult()
    gr.speak("Jake")
    ins.speak("Mike")
from greeter import Greeter

if __name__ == '__main__':
    try:
        i = input(
            "Сколько раз Вас нужно приветствовать (введите целое число, например, 2)?: "
        )
        for _ in range(int(i)):
            Greeter().greet()
    except ValueError:
        print(f"Введённые Вами символы (\"{i}\") не являются целым числом!")
Example #30
0
 def test_greet(self):
     greeter = Greeter('World!')
     self.assertEqual(greeter.greet(), 'Hello, World!')
Example #31
0
#default is world
#Author: Shubham Singh ([email protected])
from greeter import Greeter
import sys
if len(sys.argv) > 1:
    name = sys.argv[1]
else:
    name = "world"

gr = Greeter(name)
gr.greet()
    def test_greet(self):

        greeter = Greeter()

        self.assertEqual("Hello, Joe", greeter.greet("Joe"))