Exemplo n.º 1
0
    '/recipes' : 'recipes',
    '/recipes_add' : 'recipes_add',
    '/inventory' : 'inventory',
    '/inventory_add' : 'inventory_add',
    '/liquor_types' : 'liquor_types',
    '/liquor_types_add' : 'liquor_types_add',
    '/songs' : 'songs',
    '/songs_add' : 'songs_add',
    '/convert_form' : 'convert_form',
    '/do_convert' : 'do_convert',
    '/rpc'  : 'dispatch_rpc'
}

html_headers = [('Content-type', 'text/html')]

db.load_db("database.db")

usernames = {}

class SimpleApp(object):
    def __call__(self, environ, start_response):

        path = environ['PATH_INFO']
        fn_name = dispatch.get(path, 'error')

        # retrieve 'self.fn_name' where 'fn_name' is the
        # value in the 'dispatch' dictionary corresponding to
        # the 'path'.
        fn = getattr(self, fn_name, None)

        if fn is None:
Exemplo n.º 2
0
#! /usr/bin/env python

import os

from drinkz import db, recipes


db._reset_db()

db.load_db('savedtestdb')


if db._check_bottle_type_exists('Johnnie Walker', 'Black Label'):
  present = 'Black Label'
if db._check_bottle_type_exists('Anheuser-Busch', 'Bud Light'):
  presen = 'Bud Light'

                                                
r = recipes.Recipe() 

d = r.need_ingredients()

for k in d:
  print d[k]


i = 0


value = db.get_recipe('scotch on the rocks')
Exemplo n.º 3
0
#! /usr/bin/env python

import os
import drinkz.db
import drinkz.recipes
import sys
from drinkz.db import save_db, load_db

if __name__ == '__main__':
    args = sys.argv
    try:
	filename = args[1]
    except:
	filename = 'myTest'

    load_db('bin/'+filename)


try:
    os.mkdir('html')
except OSError:
    pass


###
fp = open('html/index.html', 'w')
print >>fp, "<p><a href='recipes.html'>RECIPES</a><p><a href='inventory.html'>INVENTORY</a><p><a href='liquor_types.html'>LIQUOR TYPES</a>"

fp.close()

###
Exemplo n.º 4
0
from drinkz import db
from drinkz import recipes
import os
import sys

if len(sys.argv) != 2:
    print >>sys.stderr, "Usage: %s <filename>" % sys.argv[0]
    sys.exit(1)

db.load_db(sys.argv[1])

# everything will go into the html directory
try:
    os.mkdir('html')
except OSError:
    # already exists
    pass

# nav bar
base_url = 'http://www.cse.msu.edu/~newrockm/cse491/drinkz'
index_link = '<a href="%s/index.html">Index</a>' % base_url
liquor_types_link = '<a href="%s/liquor_types.html">Liquor Types</a>' % base_url
inventory_link = '<a href="%s/inventory.html">Inventory</a>' % base_url
recipes_link = '<a href="%s/recipes.html">Recipes</a>' % base_url

navbar = """
<div style="text-align:center">
    [ %s 
    | %s 
    | %s 
    | %s ]
Exemplo n.º 5
0
def main():

	db._reset_db()

	db.load_db("database")



	###
	try:
		os.mkdir('html')
	except OSError:
		# already exists
		pass


	###

	fp = open('index.html', 'w')

	print >>fp, """<html>
	<head>
	<title>The Lush - A Alcoholic Database.</title>
	<style type='text/css'>
	h1 {color:black;}
	body {
	font-size: 14px;
	}
	</style>
	<script>
	function myFunction()
	{
	alert("Hello! I am an alert box!");
	}
	</script>
	</script>
<script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
	</head>
	<body>
	"""

	print >>fp, "<h1>Welcome to The Lush.</h1>" 

	print >>fp, "<p><a href='liquortypes'>Types of Liquor</a> "
	print >>fp, "<a href='inventory'>Inventory of Booze</a> "
	print >>fp, "<a href='recipes'>Recipe List</a> "
	print >>fp, "<a href='form'>Convert-to-ml</a> "

	print >>fp, "<p><p> This will one day be the ultimate tool for any hardy drinker. Sadly it is still a work in development. <p>Feel free to try out the available tools. <p>Remember you must be signed in to vote on recipes!"


	fp.close()

	###


	###

	fp = open('html/liquor_types.html', 'w')
	print >>fp, """<html>
	<head>
	<title>Liquor Types.</title>
	<style type='text/css'>
	h1 {color:black;}
	body {
	font-size: 14px;
	}
	</style>
	</script>
	</head>
	<body>
	"""
	print >>fp, "<h1>Types of Liquor </h1> "
	print >>fp, "<p><a href='/'>HomePage</a> "
	print >>fp, "<a href='liquortypes'>Types of Liquor</a> "
	print >>fp, "<a href='inventory'>Inventory of Booze</a> "
	print >>fp, "<a href='recipes'>Recipe List</a> "
	print >>fp, "<p><a href='form_add_type'>Add a New Type</a> "
	print >>fp, '<script type="text/javascript"src="jquery-1.2.6.min.js"></script><script type="text/javascript" src="jquery.form.js"></script><script type="text/javascript" src="application.js"></script>'


	print >>fp, "<b><p>Liquor<p></b>"


	###

	###

	fp = open('html/inventory.html', 'w')

	print >>fp, """<html>
	<head>
	<title>Inventory Page.</title>
	<style type='text/css'>
	h1 {color:black;}
	body {
	font-size: 14px;
	}
	</style>
	</script>
	</head>
	<body>
	"""
	print >>fp, "<h1>Current Inventory </h1> "
	print >>fp, "<p><a href='/'>HomePage</a> "
	print >>fp, "<a href='liquortypes'>Types of Liquor</a> "
	print >>fp, "<a href='inventory'>Inventory of Booze</a> "
	print >>fp, "<a href='recipes'>Recipe List</a> "
	print >>fp, "<p><a href='form_add_inv'>Add a New Inventory</a> "

	print >>fp, "<b><p>Name   :  Liquor    :   Amount in ml<p></b>"

	fp.close()

	###

	###

	fp = open('html/recipes.html', 'w')

	print >>fp, """<html>
	<head>
	<title>Recipe List.</title>
	<style type='text/css'>
	h1 {color:black;}
	body {
	font-size: 14px;
	}
	</style>
	</script>
	</head>
	<body>
	"""

	print >>fp, "<h1>Recipes </h1> "
	print >>fp, "<p><a href='/'>HomePage</a> "
	print >>fp, "<a href='liquortypes'>Types of Liquor</a> "
	print >>fp, "<a href='inventory'>Inventory of Booze</a> "
	print >>fp, "<a href='recipes'>Recipe List</a> "
	print >>fp, "<p><a href='form_add_recipe'>Add a New Recipe</a> "
	print >>fp, "<p>If you are logged in voting forms will appear next to each recipe. <p> Feel free to throw in your opinion and help decide what recipe is forever the best. <p> Scores are from 1-5 "
	print >>fp, "<b><p>Score  :  Name   :  Ingredients<p></b>"



	fp.close()

	###
	return 0
Exemplo n.º 6
0
scotch_on_the_rocks = recipes.Recipe('scotch on the rocks', [('blended scotch',
                                                   '4 oz')])
db.add_recipe(scotch_on_the_rocks)

martini = recipes.Recipe('vodka martini', [('unflavored vodka', '6 oz'),
                                            ('vermouth', '1.5 oz')])
db.add_recipe(martini)

bad_martini = recipes.Recipe('vomit inducing martini', [('orange juice',
                                                      '6 oz'),
                                                     ('vermouth',
                                                      '1.5 oz')])
db.add_recipe(bad_martini)
"""

db.load_db("test_database")

###
fp = open('html/index.html', 'w')
print >> fp, "<p><a href='recipes.html'>Recipes</a>"
print >> fp, "<a href='inventory.html'>Inventory</a>"
print >> fp, "<a href='liquor_types.html'>Liquor Types</a>"

fp.close()
###

###
fp = open('html/recipes.html', 'w')
print >> fp, "<p><table>"
print >> fp, "<td><b><u>Recipe</u><b/></td><td><b><u>Have ingredients?</u></b></td>"
for recipe in db._recipe_db:
Exemplo n.º 7
0
#! /usr/bin/env python

import os

from drinkz import db,recipes

# Populating the db

db.load_db("bin/db.txt")


try:
    os.mkdir('html')
except OSError:
    # already exists
    pass

###

fp = open('html/index.html', 'w')



print >>fp, """

<a href='recipes.html'>Recipes</a></br>
<a href='inventory.html'>Inventory</a></br>
<a href='liquor_types.html'>Liquor Types</a></br>

"""
Exemplo n.º 8
0
from Cookie import SimpleCookie
import uuid

from drinkz import db, recipes

# import db
import imp

# CALL make-test-database then check that it works
# scriptpath = 'bin/make-test-database'
filename = "db.txt"
usernames = {}
# module = imp.load_source('llt', scriptpath)
# exit_code = module.main([scriptpath, filename])

db.load_db(filename)

r = recipes.Recipe("scotch on the rocks", [("blended scotch", "4 oz")])
r.rate(3)
db.add_recipe(r)

r = recipes.Recipe("test recipe", [("gin", "4 oz")])
r.rate(2)
r.rate(1)

db.add_recipe(r)

r = recipes.Recipe("the best drink", [("unflavored vodka", "1 oz"), ("blended scotch", "10 ml")])
r.rate(5)
db.add_recipe(r)
Exemplo n.º 9
0
 def load_db_file(self, file_name):
     db.load_db(file_name)
Exemplo n.º 10
0
def main(args):
   filename = args[1]
	
   save_db(filename)
   load_db(filename)
Exemplo n.º 11
0
if __name__ == '__main__':
    import random, socket
    port = random.randint(8000, 9999)
    
    #create environ/start_response
    environ = {}
    environ['PATH_INFO'] = '/'
    
    d = {}
    def my_start_response(s, h, return_in=d):
        d['status'] = s
        d['headers'] = h

    populate_database()
    db.load_db('bin\drinkz.txt')

    app = SimpleApp()
    results = app(environ, my_start_response)
    
    text = "".join(results)
    status, headers = d['status'], d['headers']
    
    assert text.find('Table of Contents') != -1, text
    assert ('Content-Type', 'text/html') in headers
    assert status == '200 OK'

    httpd = make_server('', port, app)
    print "Serving on port %d..." % port
    print "Try using a Web browser to go to http://%s:%d/" % \
          (socket.getfqdn(), port)
Exemplo n.º 12
0
def main(args):
    filename = args[1]

    load_db(filename)
Exemplo n.º 13
0
#! /user/bin/env python

import os
from drinkz import db
from drinkz import recipes

#fill the database
try:
	db.load_db('./bin/database')
except Exception:
	db.add_bottle_type('Johnnie Walker', 'black label', 'blended scotch')
	db.add_to_inventory('Johnnie Walker', 'black label', '500 ml')

	db.add_bottle_type('Uncle Herman\'s', 'moonshine', 'blended scotch')
	db.add_to_inventory('Uncle Herman\'s', 'moonshine', '5 liter')

	db.add_bottle_type('Gray Goose', 'vodka', 'unflavored vodka')
	db.add_to_inventory('Gray Goose', 'vodka', '1 liter')

	db.add_bottle_type('Rossi', 'extra dry vermouth', 'vermouth')
	db.add_to_inventory('Rossi', 'extra dry vermouth', '24 oz')
	
	r = recipes.Recipe('scotch on the rocks', [('blended scotch', '4 oz')])
	db.add_recipe(r)

	r = recipes.Recipe('vodka martini', [('unflavored vodka', '6 oz'),('vermouth', '1.5 oz')])
	db.add_recipe(r)

	r = recipes.Recipe('vomit inducing martini', [('orange juice','6 oz'),('vermouth','1.5 oz')])
	db.add_recipe(r)