示例#1
0
文件: wineprint.py 项目: jkobrin/pos1
def fodt_text():
  doc = open('/var/www/winelist_head.xml.frag').read()
  for frag in get_wine_xml():
    doc += frag
  if utils.hostname() == 'plansrv':
    doc += open('/var/www/winefun.xml.frag').read()
  doc += open('/var/www/winelist_tail.xml.frag').read()

  return doc
示例#2
0
def get_wine_xml():  

  winecats = utils.select('''
    select category from active_wine 
    where active = true and listorder > 0 and bin is not null 
    group by category order by min(listorder)''')

  for num, cat in enumerate(winecats):
    cat = cat['category']

    wine_items = utils.select('''
      select * from active_wine
      where category = '%(cat)s'
      and listorder > 0
      and bin != '0'
      order by listorder
      ''' % locals())

    if cat in ('Red Wine', 'Bubbly', 'Bottled Beer', 'House Cocktails') or utils.hostname() == 'plansrv' and cat == 'White Wine':
      style = 'P19' #this style starts new page
    else:
      style = 'P20'

    yield '''
   <text:h text:style-name="%s">%s</text:h>
   ''' % (style, escape(cat))

    if cat in ('House Cocktails', 'Bottled Beer'):	
      yield '''<text:p/>'''


    current_subcategory = None

    for item in wine_items:
      binnum, name, listprice, byline, grapes, notes, subcategory  = (
        clean(escape(unicode(item[key]))) for key in ['bin', 'name', 'listprice', 'byline', 'grapes', 'notes', 'subcategory']
      )

      # do location heading if location changed
      if current_subcategory != subcategory and subcategory is not None:
        current_subcategory = subcategory
        yield '''<text:p text:style-name="Psubcat"><text:span text:style-name="T1">%s</text:span></text:p>'''%subcategory

      yield '''<text:p text:style-name="P4">%s.<text:tab/>%s<text:s text:c="5"/>%s'''%(binnum, name, listprice)

      if byline:
        yield '''<text:line-break/>%s''' % byline
      if grapes:
        yield '''<text:line-break/>Grapes: %s''' % grapes
      if notes:
        yield '''<text:line-break/>%s''' % notes
      yield '</text:p>'
      yield '''<text:p text:style-name="P18"/>'''
      
      if cat in ('House Cocktails', 'Bottled Beer'):	
      	yield '''<text:p/>'''
示例#3
0
def get_stub_data(person_id, week_of, table_name, incursor):  

  print person_id, week_of
  stub_data = utils.select('''
    select 
    last_name as LAST_NAME,
    first_name as FIRST_NAME,
    "000-00-0000" as SOCIAL,
    week_of + interval '1' week as PERIOD_END,
    concat(week_of, ' - ', week_of + interval '6' day) as PERIOD_SPAN,
    fed_withholding as FED,
    social_security_tax as SOC,
    medicare_tax as MED,
    nys_withholding as STATE,
    gross_wages as GROSS,
    gross_wages - fed_withholding - social_security_tax - medicare_tax - nys_withholding as NET,
    round(gross_wages / pay_rate,2) as HOURS,
    pay_rate as RATE
    from {table_name}
    where person_id = {person_id}
    and week_of = "{week_of}"
  '''.format(**locals()), incursor
  )

  stub_ytd_data = utils.select('''
    select 
    sum(fed_withholding) as FEDYTD,
    sum(social_security_tax) as SOCYTD,
    sum(medicare_tax) as MEDYTD,
    sum(nys_withholding) as STATEYTD,
    sum(gross_wages) as GYTD,
    sum(gross_wages - fed_withholding - social_security_tax - medicare_tax - nys_withholding) as NETYTD
    from {table_name}
    where person_id = {person_id}
    and year("{week_of}" + interval '1' week) = year(week_of+interval '1' week) 
    and week_of <= date("{week_of}")
  '''.format(**locals()), incursor
  )

  # make one dictionary of the two result sets
  result = stub_data[0] # start with stub_data
  result.update(stub_ytd_data[0]) #add the YTD stuff to it

  if utils.hostname() == 'salsrv':
    result["BUSS_INFO_LINE"] = "SALUMI dba Ultraviolet Enterprises 5600 Merrick RD, Massapequa, NY 11758 516-620-0057"
  else:  
    result["BUSS_INFO_LINE"] = "PLANCHA dba Infrared Enterprises 931 Franklin AVE, GardenCity, NY 516-246-9459"
  return result
示例#4
0
import matplotlib
import utils

if utils.hostname() != 'user':
    matplotlib.use('Agg')

import matplotlib.pyplot as plt
import warnings
import numpy as np
import matplotlib.animation as animation

warnings.simplefilter('ignore')
anim_running = True


def plot_slice_3d_2(image3d, mask, axis, pid, img_dir=None, idx=None):
    fig, ax = plt.subplots(2, 2, figsize=[8, 8])
    fig.canvas.set_window_title(pid)
    masked_image = image3d * mask
    if idx is None:
        roi_idxs = np.where(mask == 1.)
        if len(roi_idxs[0]) > 0:
            idx = (np.mean(roi_idxs[0]), np.mean(roi_idxs[1]),
                   np.mean(roi_idxs[2]))
        else:
            print('No nodules')
            idx = np.array(image3d.shape) / 2
    else:
        idx = idx.astype(int)
    if axis == 0:  # sax
        ax[0, 0].imshow(image3d[idx[0], :, :], cmap=plt.cm.gray)
示例#5
0
import matplotlib
import utils

if utils.hostname() != 'user':
    matplotlib.use('Agg')

import matplotlib.pyplot as plt
import warnings
import numpy as np
import matplotlib.animation as animation

warnings.simplefilter('ignore')
anim_running = True


def plot_slice_3d_2(image3d, mask, axis, pid, img_dir=None, idx=None):
    fig, ax = plt.subplots(2, 2, figsize=[8, 8])
    fig.canvas.set_window_title(pid)
    masked_image = image3d * mask
    if idx is None:
        roi_idxs = np.where(mask == 1.)
        if len(roi_idxs[0]) > 0:
            idx = (np.mean(roi_idxs[0]), np.mean(roi_idxs[1]), np.mean(roi_idxs[2]))
        else:
            print 'No nodules'
            idx = np.array(image3d.shape) / 2
    else:
        idx = idx.astype(int)
    if axis == 0:  # sax
        ax[0, 0].imshow(image3d[idx[0], :, :], cmap=plt.cm.gray)
        ax[0, 1].imshow(mask[idx[0], :, :], cmap=plt.cm.gray)
示例#6
0
import yaml, json
from mylog import my_logger
import utils
from texttab import TAXRATE
log = my_logger

CONFIG_FILE_NAME = '/var/www/' + utils.hostname() + '_config.yml'

MAX_NAME_LEN = 32

def iget():
  items = {}
  cfg = yaml.load(open(CONFIG_FILE_NAME))
  populate_wine_category(cfg)  
  populate_staff_tabs(cfg)

  for category in cfg['menu']['categories']:
    catname = category['name']
    for subcat in category['subcategories']:
      subcatname = subcat['name']
      for item in subcat['items']:
        item['catname'] = catname
        item['subcatname'] = subcatname
        if not item.has_key('name'):
           raise Exception('no name for item: ' + str(item))
        item['name'] = unicode(item['name'])[:MAX_NAME_LEN]
        if subcat.get('tax') == 'included' and item.get('price'):
          item['price'] /= (1 + TAXRATE) # remove the tax from price
        items[item['name']] = item
  return cfg, items
import json
import utils
import os
import utils_lung

if utils.hostname() == 'user':
    with open('SETTINGS_user.json') as data_file:
        paths = json.load(data_file)
else:
    with open('SETTINGS.json') as data_file:
        paths = json.load(data_file)

# kaggle data
STAGE = int(paths["STAGE"])

if STAGE == 1:
    METADATA_PATH = paths["METADATA_PATH_1"]

    DATA_PATH = paths["DATA_PATH_1"]
    utils.check_data_paths(DATA_PATH)

    SAMPLE_SUBMISSION_PATH = paths["SAMPLE_SUBMISSION_PATH_1"]
    if not os.path.isfile(SAMPLE_SUBMISSION_PATH):
        raise ValueError('no stage 1 sample submission file')

elif STAGE == 2:
    METADATA_PATH = paths["METADATA_PATH_2"]

    DATA_PATH = paths["DATA_PATH_2"]
    utils.check_data_paths(DATA_PATH)
示例#8
0
import json
import utils
import os
import utils_lung

if utils.hostname() == 'user':
    with open('SETTINGS_user.json') as data_file:
        paths = json.load(data_file)
else:
    with open('SETTINGS.json') as data_file:
        paths = json.load(data_file)

# kaggle data
STAGE = int(paths["STAGE"])

if STAGE == 1:
    METADATA_PATH = paths["METADATA_PATH_1"]

    DATA_PATH = paths["DATA_PATH_1"]
    utils.check_data_paths(DATA_PATH)

    SAMPLE_SUBMISSION_PATH = paths["SAMPLE_SUBMISSION_PATH_1"]
    if not os.path.isfile(SAMPLE_SUBMISSION_PATH):
        raise ValueError('no stage 1 sample submission file')

elif STAGE == 2:
    METADATA_PATH = paths["METADATA_PATH_2"]

    DATA_PATH = paths["DATA_PATH_2"]
    utils.check_data_paths(DATA_PATH)