Exemplo n.º 1
0
def generate_pdf():
    '''his methods generates pdf report of cinemas statistics
    There are informations like: total sum of selled tickets or total income'''
    pdf_filename = 'cinemas_report.pdf'
    c = canvas.Canvas(pdf_filename, pagesize=portrait(A4))

    w = defaultPageSize[0]
    h = defaultPageSize[1]

    c.setFont('Helvetica', 35, leading=None)
    c.drawCentredString(w / 2, 740, "Reports of the Cinemas")

    cinemas = list_of_cinemas()
    cinemas_stats = cinema_stats()
    cnx, cursor = create_connection()
    for name, cinema_id in cinemas:
        c.setFontSize(20)
        c.drawCentredString(w / 2, 600, name)
        c.setFontSize(16)
        text = "Total sum of selled tickets: {}".format(
            cinemas_stats[cinema_id][0])
        c.drawString(w / 10, 520, text)
        text = "Averrage amount of tickets selled per movie: {}".format(
            cinemas_stats[cinema_id][1])
        c.drawString(w / 10, 490, text)
        text = "Percentage: {}".format(
            cinemas_stats[cinema_id][2])
        c.drawString(w / 10, 460, text)
        text = "Total income: {} PLN".format(
            cinemas_stats[cinema_id][3])
        c.drawString(w / 10, 430, text)
        c.showPage()
    close_connection(cnx, cursor)
    c.save()
    return True
Exemplo n.º 2
0
 def __init__(self):
     """Init method."""
     self.connection = create_connection()
     self.cursor = self.connection.cursor()
     self.table_name = input("Enter table name: ")
     self.table_tuple = self.table_columns()
     create_table(self.cursor, self.connection, self.table_name,
                  *self.table_tuple)
     self.user_info = self.user_info(*self.table_tuple)
     insert_data(self.cursor, self.connection, self.table_name,
                 *self.user_info)
     permission = input("Do you want to update a table(y/n): ")
     if permission == 'y':
         self.update_params = self.update_params()
         update_table(self.cursor, self.connection, self.table_name,
                      **self.update_params)
     else:
         pass
     permission = input("Do you want to drop a table(y/n): ")
     while permission == 'y':
         if permission == 'y':
             table_name = input("Enter the table name")
             drop_table(self.cursor, self.connection, table_name)
             permission = input("Do you want to drop a table(y/n): ")
         else:
             break
     self.connection.close()
Exemplo n.º 3
0
def generate_xls():
    '''This methods generates xls document of cinemas statistics
    There are informations like: total sum of selled tickets or total income'''
    xls_filename = 'raport.xls'
    cnx, cursor = create_connection()
    workbook = xlsxwriter.Workbook(xls_filename)
    worksheet = workbook.add_worksheet()

    # Add a bold format to use to highlight cells.
    bold = workbook.add_format({'bold': 1})
    bold.set_align('center')

    # Add a number format for cells with money.
    money_format = workbook.add_format({'num_format': '#,##0 ZŁ'})
    money_format.set_align('center')

    # Adjust the column width.
    worksheet.set_column(1, 0, 40)
    worksheet.set_column(1, 1, 40)
    worksheet.set_column(1, 2, 40)
    worksheet.set_column(1, 3, 40)

    # center cells
    cell_format = workbook.add_format()
    cell_format.set_align('center')

    worksheet.write('A1', "Cinemas", bold)
    worksheet.write('A2', 'Selled tickets', bold)
    worksheet.write('A3', 'Tickets per movie', bold)
    worksheet.write('A4', 'Total Income', bold)

    info = cinema_stats()
    row = 0
    col = 1
    for cinema_id in info:
        sql = '''
        SELECT name FROM cinemas 
        WHERE cinema_id = %s
        '''
        cursor.execute(sql, (cinema_id,))
        cinema_name = cursor.fetchone()[0]
        worksheet.write(row, col, cinema_name, bold)
        worksheet.write(row + 1, col, info[cinema_id][0], cell_format)
        worksheet.write(row + 2, col, info[cinema_id][1], cell_format)
        worksheet.write(row + 3, col, info[cinema_id][3], cell_format)
        col += 1
    close_connection(cnx, cursor)
Exemplo n.º 4
0
import connect
import test010_list_interface
import test011_create_interface
import test012_delete_interface

try:
    c = connect.create_connection('http://127.0.0.1/identity', 'admin',
                                  'admin', 'secret', 'RegionOne', 'default',
                                  'default')

    while True:
        print("\r\n---Manage Interfaces----------------------------------")
        print("Select one of the following option:")
        print(
            "Select 1 to List Interfaces\r\nSelect 2 to Create Interfaces\r\nSelect 3 to Delete Interfaces\r\nSelect 0 to Exit\r\n"
        )
        while True:
            try:
                selection = int(raw_input("Your input: "))
            except ValueError:
                print("Please select one of the option.")
                continue
            else:
                break

        if selection == 0:
            print("Exit Program.")
            exit()
        elif selection == 1:
            list_int = test010_list_interface.List()
            list_int.list_router_interface(c)
Exemplo n.º 5
0
from flask import Flask, request, abort
from linebot import (LineBotApi, WebhookParser)
from linebot.exceptions import (InvalidSignatureError)
from linebot.models import (MessageEvent, TextMessage, TextSendMessage,
                            FileMessage)
from flask_sqlalchemy import SQLAlchemy

# from Download import download_file

app = Flask(__name__)
db = SQLAlchemy(app)
from connect import create_connection

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{}'.format(
    create_connection('Test01'))

#### _____________ end g drive setup_____________#####

# get channel_secret and channel_access_token from your environment variable

line_bot_api = LineBotApi(
    '1RfIiAbjneORMpj+sIGYx+Yi0esjdG/F/VQxyIc6/dFoCVym6hZzDrBqxpd5Ui8XFLsdzohfRuvZRU1dsCP0yaSN3Rdx7U3PeT/0kZfnkrAXrmtrclZaw0v/tA6vOe2fM93R+JvDab5xhxN/4vtGYQdB04t89/1O/w1cDnyilFU='
)
parser = WebhookParser('31d9c964d1afd080749b16d09f2f016c')

#### ให้ลอง download file จาก line


@app.route("/callback", methods=['POST'])
def callback():
Exemplo n.º 6
0
parser.add_argument('-f', '--From', help="From, sender")
parser.add_argument('-t', '--to', help="Receiver username")
parser.add_argument('-s', '--send', help="Message to send")
parser.add_argument('-H', '--history', action="store_true",
                    help="History of conversation beetween 2 users")
args = parser.parse_args()

# Scenarios:
# 1. -u -p -E -e <-- creating new user/ updating existing user
# 2. -u -p -d    <-- removing user (if exists in TABLE)
# 3. -l          <-- list of all users
# 4. -u -p -s -t <-- send message from logged user to another user (both have to exist)
# 5. -F -t -H    <-- show full history of conversation beetween two users


cnx, cursor = create_connection()
# creating object to work on
user = Users()

# creating new user to database users
if args.username and args.password and args.email and args.edit:
    user.id = user.get_id(args.username, cursor)
    user.save_to_db(args.username, args.password, args.email, cursor)


# removing user(if exists)
if args.username and args.password and args.delete:
    user.id = user.get_id(args.username, cursor)
    user.validate_data(args.username, args.password, cursor)
    if user.id != -1 or user.validate_data(args.username, args.password, cursor):
        user.delete(cursor)