def __update_file_or_dir_node (self, file_or_dir_node, source, attributes, metadata):
        # Set properties

        unlink_children (file_or_dir_node)

        file_or_dir_node.setProp ("timestamp", str (int (time.time ())))
        file_or_dir_node.setProp ("user",      util.get_user_name ())
        file_or_dir_node.setProp ("host",      socket.gethostname ())

        # Set source and attributes
        file_or_dir_node.newChild (None, "source", source)

        attributes_node = file_or_dir_node.newChild (None, "attributes", None)
        if attributes:
            for name in attributes:
                attribute_node = attributes_node.newChild (None, "attribute", None)
                attribute_node.setProp ("name",  str (name))
                attribute_node.setProp ("value", str (attributes[name]))
Exemple #2
0
    def __init__(self):
        super(mainWindow, self).__init__()
        # get UI
        self.ui = uic.loadUi('pyQt_study02.ui', self)

        # user name
        user = util.get_user_name()
        self.ui.lineEdit_user.setText(user)

        # project List
        projectList = util.get_folder_list("P:/")
        # print projectList
        self.ui.comboBox_project.addItems(projectList)

        # signals
        self.ui.comboBox_project.activated[str].connect(self.changeProject)
        self.ui.listView_assetType.clicked.connect(self.addAssetList)
        self.ui.listView_asset.clicked.connect(self.addAssetComponent)
        self.ui.listView_assetComponent.clicked.connect(self.showAssetHistory)
Exemple #3
0
    def __init__(self):
        super(mainWindow, self).__init__()
        # get UI
        self.ui = uic.loadUi('pyQt_study02.ui', self)

        # user name
        user = util.get_user_name()
        self.ui.lineEdit_user.setText(user)

        # project List
        projectList = util.get_folder_list("P:/")
        # print projectList
        self.ui.comboBox_project.addItems(projectList)

        # signals
        self.ui.comboBox_project.activated[str].connect(self.changeProject)
        self.ui.listView_assetType.clicked.connect(self.addAssetList)
        self.ui.listView_asset.clicked.connect(self.addAssetComponent)
        self.ui.listView_assetComponent.clicked.connect(self.showAssetHistory)

        # add default preview image.
        # 'N:/b1Env/maya/2014/icons/noPreview.jpg'
        dataEmpty = QtCore.QStringList()
        self.modelEmpty = QtGui.QStringListModel(dataEmpty)
Exemple #4
0
    def handle_app(self, attr):
        # Get access token
        access_token = attr['access_token']

        # Pick random image
        random_image = get_random_image_path()

        # NOTE: This assumes the user has already made a ride request
        request_id = make_fake_ride_request(access_token)
        ride_info = get_ride_info(access_token, request_id)
        driver = ride_info.get('driver')
        
        if driver == None:
            # Send failure page
            self.send_response(200)
            self.send_header('Content-type', 'text/html')
            self.end_headers()
            self.wfile.write(bytes("You don't have an accepted ride request! Make one and try again", 'UTF-8'))
            return

        driver_name = driver['name']
        driver_phone = driver['phone_number']

        passenger_name = get_user_name(access_token)
        
        # Generate app page with image
        app_page = success_page('flags/'+random_image, driver_name, passenger_name)

        # Send flag image to driver
        text_image(driver_phone, passenger_name, 'https://hueber.io/flags/'+random_image)

        # Send app page
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        self.wfile.write(bytes(app_page, 'UTF-8'))
Exemple #5
0
def execute(req, resp):
    # 台帳を全行取得
    select_ledger_list = 'SELECT id, name, quantity, note, last_update FROM ledger ORDER BY id ASC'
    # 最終取得日時を更新
    update_last_access = "REPLACE INTO last_access (user_name, date) VALUES (?,datetime('now', '+9 hours'))"

    result_row = None
    result = []
    user_name = util.get_user_name(req)

    # クエリを実行する
    with closing(sqlite3.connect(transaction_db.DBNAME)) as conn:
        c = conn.cursor()
        c.execute(select_ledger_list)
        result_row = c.fetchall()

        c.execute(update_last_access, (user_name, ))
        conn.commit()

    # データを整形する
    for row in result_row:
        result.append({
            'id': row[0],
            'name': row[1],
            'quantity': row[2],
            'note': row[3],
            'last_update': row[4],
        })

    # responseをUTF-8のJSONとして返す
    resp.headers = {"Content-Type": "application/json; charset=utf-8"}
    resp.content = json.dumps({
        'success': True,
        'result': result
    },
                              ensure_ascii=False)
Exemple #6
0
async def execute(req, resp):
    select_ledger = 'SELECT id, name, quantity, note, last_update FROM ledger WHERE id=?'
    get_last_access = 'SELECT user_name, date FROM last_access WHERE user_name=?'
    insert_ledger = "INSERT INTO ledger (name, quantity, note, last_update) VALUES (?,?,?,datetime('now', '+9 hours'))"
    update_ledger = "UPDATE ledger SET name=?, quantity=?, note=?, last_update=datetime('now', '+9 hours') WHERE id=?"
    add_write_history = "INSERT INTO write_history (id, name, quantity, note, success, date) VALUES (NULL,?,?,?,?,datetime('now', '+9 hours'))"
    # 最終取得日時を更新
    update_last_access = "REPLACE INTO last_access (user_name, date) VALUES (?,datetime('now', '+9 hours'))"

    user_name = util.get_user_name(req)
    success = True
    message = ''

    id = None
    name = None
    quantity = None
    note = ''

    data = await req.media()
    if data.get('id'):
        id = data.get('id')
    if data.get('name'):
        name = data.get('name')
    if data.get('quantity'):
        quantity = data.get('quantity')
    if data.get('note'):
        note = data.get('note')

    # note以外入力されていればOKとする
    if name and quantity:
        with closing(sqlite3.connect(transaction_db.DBNAME)) as conn:
            c = conn.cursor()

            # 台帳の特定の1行取得
            c.execute(select_ledger, (id, ))
            ledger_exists = c.fetchone()

            if ledger_exists:
                # 同じidのデータがある場合
                c.execute(get_last_access, (user_name, ))
                last_login = c.fetchone()

                if last_login and ledger_exists[4] <= last_login[1]:
                    # 更新可能 台帳の1行更新
                    c.execute(update_ledger, (name, quantity, note, id))
                else:
                    # このユーザーのデータ取得後に行更新があった場合はUpdateさせない
                    success = False
                    message = '他のユーザーによってデータが変更されている可能性があります'

            else:
                # 新規データ場合 台帳に1行追加
                c.execute(insert_ledger, (name, quantity, note))

            # 最後に、成否に関わらず履歴を残す
            c.execute(add_write_history, (name, quantity, note, success))
            c.execute(update_last_access, (user_name, ))

            conn.commit()

        # バックアップファイルを上書きする
        transaction_db.save_file()
    else:
        success = False
        message = '更新データに不備があります'

    result = {}
    if success:
        result = {
            'success': True,
        }
    else:
        result = {'success': False, 'message': message}

    # responseをUTF-8のJSONとして返す
    resp.headers = {"Content-Type": "application/json; charset=utf-8"}
    resp.content = json.dumps(result, ensure_ascii=False)