Exemplo n.º 1
0
def option_saem(request, data):
  if data.get('name') != 'SAEM':
    return

  rb = rainbow.make_rainbow(data)
  data['rainbow'] = rb
  data['rainbow_html'] = rainbow.rainbow(rb)
Exemplo n.º 2
0
def main():
	w = turtle.Screen()
	w.setup(1500, 1000)
	w.clear()
	w.bgcolor("#ffffff")
	w.title('A rainbow over the olympic rings next to a triggered turtle')
	t = turtle.Turtle()
	t.speed(0)

	rainbow.rainbow(t)
	print('\'rainbow.py\' Done!')
	olympicRings.rings(t)
	print('\'olympicRings.py\' Done!')
	triggeredTurtle.turt(t)
	print('\'triggeredTurtle.py\' Done!')


	w.exitonclick()
Exemplo n.º 3
0
colors = [
    "magenta", "pink", "navy", "blue", "red", "yellow", "orange", "white"
]

# --------------------

print()
print("Started")
t.bgcolor("cyan")
t.hideturtle()
t.penup()
t.speed(0)
t.pensize(3)

draw_sun()
r.rainbow(600, 300, -100)

# ---------------------------------------------------------------------
# Examples:
#
#   draw_flower(Size, X, Y, PetalColor, CenterColor, Angle, PetalCount)
#
#   randint(1, 6)
#     Returned value may be: "4";
#
#   choise("Python", "HTML", "JavaScript")
#     Returned value may be: "Python";
#
# ---------------------------------------------------------------------

for i in range(4):
Exemplo n.º 4
0
import turtle as t
import rainbow as r

t.goto(-300, -100)
r.move_l(600)


t.goto(300, -100)
r.rainbow(600)
t.turtlesize(2)
t.goto(0, -100)

num = 500
for i in range(num):
    t.color('#00004d', (r.calculate_y1(num, 255, i), r.calculate_y2(num, 255, i), r.calculate_y3(num, 255, i)))

t.mainloop()
Exemplo n.º 5
0
def save_post(request, data, board, thread):

  board_db = Board.get_by_key_name(board)

  if not board_db:
    board_db = Board(key_name = board, thread = [])

  board_db.counter += 1

  # create new thread
  new = False
  if thread == 'new':
    new = True
    if data.get("sage"):
      raise NotFound() # FIXME: move to form

    thread = board_db.counter
    posts = []
    thread_db = Thread.create(thread, board)
    thread_db.posts = []
    thread_db.subject = data.get("subject")[:SUBJECT_MAX]
  else:
    thread = int(thread)
    #if thread not in board_db.thread:
    #  raise NotFound()

    if thread in board_db.thread and not data.get("sage"):
      board_db.thread.remove(thread)

    thread_db = Thread.load(thread, board)

    if not thread_db:
      raise NotFound()

  if not data.get("sage"):
    board_db.thread.insert(0, thread)

  board_db.thread = board_db.thread[:THREAD_PER_PAGE*BOARD_PAGES]

  rb = rainbow.make_rainbow(request.remote_addr, board, thread)
  data['rainbow'] = rb
  data['rainbow_html'] = rainbow.rainbow(rb)
  data['text_html'] = markup(
        board=board, postid=board_db.counter,
        data=escape(data.get('text', '')),
  )

  # FIXME: move to field
  data['name'] = data.get("name") or "Anonymous"

  # save thread and post number
  data['post'] = board_db.counter
  data['thread'] = thread
  now = datetime.now()
  data['time'] = now.strftime("%Y-%m-%d, %H:%M")
  data['timestamp'] = int(now.strftime("%s"))

  img_key = data.get("key")

  if img_key:
    blob_key = blobstore.BlobKey(img_key)
    blob_info = blobstore.BlobInfo.get(blob_key)

    data['image'] = {
        "size" : blob_info.size,
        "content_type" : blob_info.content_type,
        "full" : images.get_serving_url(img_key),
        "thumb" : images.get_serving_url(img_key, 200),
    }

  for fname in board_options.get(board, []):
    func = globals().get('option_'+fname)

    if func:
      func(request, data)

  thread_db.posts.append(data)

  db.put( (thread_db, board_db))
  Cache.delete(
    (
      dict(Board=board),
    )
  )
  memcache.set("threadlist-%s" % board, board_db.thread)

  memcache.set("post-%s-%d" %(board, board_db.counter), data)

  r = Render(board, thread)
  r.add(data, new)
  r.save()

  key = "update-thread-%s-%d" % (board, thread)
  if not new:
    send = { 
        "html" : r.post_html, 
        "evt" : "newpost" ,
        "count" : len(thread_db.posts),
        "last" : board_db.counter,
    }
    watchers = memcache.get(key) or []
    for person in watchers:
      logging.info("send data to key %s" % (person+key))
      channel.send_message(person+key, dumps(send))

  return board_db.counter, thread
Exemplo n.º 6
0
    print '    ' + sys.argv[0] + ' scroll [secs [fps [width]]]'
    print '    ' + sys.argv[0] + ' pulse  [secs [fps]]'
    sys.exit(0)


# Exit gracefully on sigint (ctrl+c).
def sigint(signal, frame):
    sys.stdout.write('\r')
    os.system('tput cnorm')
    sys.exit(0)


signal.signal(signal.SIGINT, sigint)

strs = file.read(sys.stdin).splitlines()
r = rainbow(fps)
t = time()
# Turn the cursor invisible
os.system('tput civis')
first = True
# Until we are out of time, draw the next frame and sleep a bit.
while not secs or time() - t < secs:
    # Do not delete written text before it has been written for the first time.
    if first:
        first = False
    else:
        sys.stdout.write("\033[" + str(len(strs)) + "A")
    for s in strs:
        sys.stdout.write("\r")

        if bar == 'scroll':
Exemplo n.º 7
0
except:
    print 'Usage:'
    print '    ' + sys.argv[0]
    print '    ' + sys.argv[0] + ' scroll [secs [fps [width]]]'
    print '    ' + sys.argv[0] + ' pulse  [secs [fps]]'
    sys.exit(0)

# Exit gracefully on sigint (ctrl+c).
def sigint(signal, frame):
    sys.stdout.write('\r')
    os.system('tput cnorm')
    sys.exit(0)
signal.signal(signal.SIGINT, sigint)

strs = file.read(sys.stdin).splitlines()
r = rainbow(fps)
t = time()
# Turn the cursor invisible
os.system('tput civis')
first = True
# Until we are out of time, draw the next frame and sleep a bit.
while not secs or time() - t < secs:
    # Do not delete written text before it has been written for the first time.
    if first:
        first = False
    else:
        sys.stdout.write("\033["+str(len(strs))+"A")
    for s in strs:
        sys.stdout.write("\r")

        if bar == 'scroll':