Esempio n. 1
0
def add_admin(emailormobile):
    user = session.query(User).filter(or_(User.email == emailormobile,User.mobile == emailormobile)).first()
    if not user:
        raise
    admin = Admin(admin_id = ut.create_admin_id(),user_id = user.user_id,created = time.time()*1000,updated = time.time()*1000)
    session.add(admin)
    session.commit()
Esempio n. 2
0
 def normalize_paths(self):
     if self.normalize:
         queryset = self.photoset.filter(~Photo.base_uri.endswith(os.sep)).all()
         if len(queryset):
             self.create_backup()
             for p in queryset:
                 p.base_uri += os.sep
             session.commit()
             logger.info(_("Normalized path separator on %s photos.") % len(queryset))
         
         if self.db_version >= DB_VERSION_ENCODED:
             total = 0
             # Look for photo without '%' in their path (i.e. not encoded)
             queryset = self.photoset.filter(~Photo.base_uri.like('%\\%%', escape="\\")).all()
             if len(queryset):
                 self.create_backup()
                 for p in queryset:
                     # Compare encoded version of base_uri to actual version
                     # (slice file:// part)
                     base_uri_encoded = urllib.quote(p.base_uri[7:].encode('utf-8'))
                     if base_uri_encoded != p.base_uri[7:]:
                         p.base_uri = p.base_uri[:7] + base_uri_encoded
                         total += 1
                 session.commit()
                 logger.info(_("Normalized path encoding on %s photos.") % total)
         self.normalize = False
Esempio n. 3
0
def recieve_message():
    try:
        message = request.form.get('message')
        json_resp = False
        if not message:
            message = request.get_json()['message']
            json_resp = True

        message_data = Message(message=message)
        session.add(message_data)
        session.commit()

        if json_resp:
            resp = {
                'status': 'success',
                'message': message
            }
            return jsonify(**resp)
        else:
            return redirect(url_for('dashboard'))


    except Exception as e:
        resp = {
            'status': 'failed',
            'error': str(e)
        }

        return jsonify(**resp)
Esempio n. 4
0
    def exec_global(self, request):
        """
        Execute a global-scoped command.
        """

        command = request["command"]

        if command == "go back to perm":
            liq.set_var("selected", "perm")
            liq.send_command("perm-switch.skip")

            self.send_feedback(request)

        elif command == "rescan":
            result = Utilities.rescan()
            self.send_feedback(request, result)

        elif command == "select":
            studio = session.query(Studio).find_by(slug=request["studio"].decode('utf-8'))

            if studio is not None:
                studio.selected = True
                session.add(studio)
                session.commit()
                liq.set_var("selected", str(studio.slug))
                sylog("INFO: Selecting " + studio.slug)
                self.send_feedback(request)
            else:
                self.send_feedback(request, "error", "Unknown studio %s" % request["studio"])
    def addEdit(self, _thread_id, _content, _submitted=False):
        existingList = (
            session.query(bot_comments_anetpool)
            .filter_by(thread_id=_thread_id)
            .order_by(desc(bot_comments_anetpool.edit_id))
            .first()
        )

        if existingList is None:
            row = bot_comments_anetpool()
            row.thread_id = _thread_id
            _from_template = self.anetpool_template.split("	", 1)
            row.content = _from_template[0] + _content + "	" + _from_template[1]
            row.submitted = _submitted
            session.add(row)
        else:
            if len(existingList.content) + len(_content) >= 10000:
                row = bot_comments_anetpool()
                row.thread_id = _thread_id
                _from_template = self.anetpool_template.split("	", 1)
                row.content = _from_template[0] + _content + "	" + _from_template[1]
                row.submitted_id = "e" + str(existingList.edit_id)
                row.submitted = _submitted
                session.add(row)
            else:
                _from_save = existingList.content.split("	", 1)
                session.query(bot_comments_anetpool).filter_by(edit_id=existingList.edit_id).update(
                    {"content": _from_save[0] + _content + "	" + _from_save[1], "submitted": False}
                )
        session.commit()
Esempio n. 6
0
def item_edit(item_title):
    categories = session.query(Category).all()
    item = session.query(Item).filter_by(
        title=item_title).one()
    user = session.query(User).filter_by(
        id=login_session.get('user_id')).one()
    if item.user is not None and item.user.id != user.id:
        return redirect(url_for('home'))
    if request.method == 'POST':
        form = vh.ItemForm(request.form, item)
        file_storage_err = vh.store_item_pic(
            item, request.files['picture'])
        if (not form.validate() or file_storage_err is not None):
            return render_template('item_edit.html',
                                   form=form,
                                   file_err=file_storage_err)
        form.populate_obj(item)
        try:
            session.add(item)
            session.commit()
        except ValueError as e:
            return "Database validation error: " + str(e)
        except SQLAlchemyError as e:
            # todo: log error, but don't display detailed message
            # for security reasons
            return "Database error: " + str(e)
        return redirect(url_for('home'))
    else:
        form = vh.ItemForm(obj=item)
        return render_template('item_edit.html',
                               form=form,
                               file_err=None)
 def add_comment(self, _thing_id, _content, _submitted=False, _signature=None):
     if _signature is None:
         _signature = self.signature
     last_id = _thing_id
     extra_len = len("\n\n--- continued below ---") + len(_signature)
     while True:
         if len(_content) <= 0:
             return
         content_parts = _content.split("\n")
         stiched_content = ""
         for part in content_parts:
             if len(stiched_content) + len(part + "\n") + extra_len <= 10000:
                 stiched_content += part + "\n"
             else:
                 break
         row = bot_comments()
         row.thing_id = last_id
         row.submitted = _submitted
         if _content[len(stiched_content) :] == "":
             row.content = stiched_content + _signature
         else:
             row.content = stiched_content + "\n\n--- continued below ---" + _signature
         session.add(row)
         session.commit()
         last_id = "i{}".format(session.query(bot_comments).order_by(desc(bot_comments.id)).first().id)
         _content = _content[len(stiched_content) :]
 def submitComments(self):
     global r
     to_be_commented = session.query(bot_comments).filter_by(submitted=False).all()
     for tbcm in to_be_commented:
         obj = r.get_info(thing_id=tbcm.thing_id)
         if tbcm.thing_id[:2] == "t3":
             try:
                 reply_obj = obj.add_comment(tbcm.content)
             except (praw.errors.InvalidSubmission):
                 self.updateSubmitted(bot_comments, tbcm.id, "del-1")
                 logging.warning("submitComment: failed (parentDeleted): {0}".format(tbcm.id))
             else:
                 self.updateSubmitted(bot_comments, tbcm.id, reply_obj.name)
                 logging.info("submitComment: submit: {0}".format(tbcm.id))
         elif tbcm.thing_id[:2] == "t1":
             try:
                 reply_obj = obj.reply(tbcm.content)
             except (praw.errors.InvalidComment):
                 self.updateSubmitted(bot_comments, tbcm.id, "del-1")
                 logging.warning("submitComment: failed (parentDeleted): {0}".format(tbcm.id))
             else:
                 self.updateSubmitted(bot_comments, tbcm.id, reply_obj.name)
                 logging.info("submitComment: submit: {0}".format(tbcm.id))
         elif tbcm.thing_id[:1] == "i":
             new_id = self.searchSubmitted(bot_comments, tbcm.thing_id[1:])
             if new_id == "del-1":
                 self.updateSubmitted(bot_comments, tbcm.id, "del-1")
             if new_id is not None:
                 self.updateThingId(bot_comments, tbcm.id, new_id)
         session.commit()
Esempio n. 9
0
def insert_test():
    tom = Teacher(name='Tom', subject='Physics')
    session.add(tom)
    session.commit()
    lucy = Student(name='Lucy', head_teacher_id=tom.id)
    session.add(lucy)
    session.commit()
Esempio n. 10
0
    def redo_compare_all_releases(self):
        """
            When problems in release comparisons are discovered, use this
            function in manual mode to recompute the release difference table.
        """
        all_releases = self.list_all_releases(self.motif_type)
        for i in xrange(len(all_releases)):
            release = all_releases[i]
            c1 = MotifCollection(release=release,type=self.motif_type)
            for j in xrange((i+1),len(all_releases)):
                print '%s vs %s' % (all_releases[i], all_releases[j])

                c2 = MotifCollection(release=all_releases[j],type=self.motif_type)
                logging.info('Comparing %s and %s' % (c1.release, c2.release))
                A = Uploader(ensembles=MotifCollectionMerger(c1,c2),
                             upload_mode='release_diff',
                             motif_type=self.motif_type)
                A.import_release()

                # set direct parent flag
                if j == i+1:
                    a = session.query(Release_diff).filter(Release_diff.release_id1==release)\
                                                   .filter(Release_diff.release_id2==all_releases[j])\
                                                   .first()
                    a.direct_parent = 1;
                    session.merge(a)
                    session.commit()
Esempio n. 11
0
 async def delete(self, instance_id):
     instance = session.query(self.factory).filter(self.factory.id == instance_id).first()
     if not instance:
         abort(404, message="{0} {1} doesn't exist".format(self.collection_name, id))
     session.delete(instance)
     session.commit()
     return Response(status=204)
Esempio n. 12
0
    async def post(self, request):
        data = await request.post()
        car = Car(model=data.get('model'), year=data.get('year'))
        session.add(car)
        session.commit()

        return await self.response_200(response_data=session.query(Car))
Esempio n. 13
0
def home(request):

    session.rollback()
    session.commit()

    filter_date = datetime.datetime.utcnow() - datetime.timedelta(seconds=60)
    
    wemo_device_count = session.query(func.count(distinct(WemoTimeSeries.device_name))).first()[0]
    wemo = session.query(WemoTimeSeries).order_by(WemoTimeSeries.datetime.desc()).limit(wemo_device_count).all()

    hue_device_count = session.query(func.count(distinct(HueTimeSeries.device_name))).first()[0]
    hue = session.query(HueTimeSeries).order_by(HueTimeSeries.datetime.desc()).limit(hue_device_count).all()

    nest = session.query(NestTimeSeries).order_by(NestTimeSeries.datetime.desc()).limit(1).first()

    apex = session.query(ApexTimeSeries).filter(ApexTimeSeries.value != None).filter(ApexTimeSeries.datetime>filter_date).all()
   
    roomba_device_count = session.query(func.count(distinct(RoombaTimeSeries.device_name))).first()[0]
    roomba = session.query(RoombaTimeSeries).order_by(RoombaTimeSeries.datetime.desc()).limit(roomba_device_count).all()
    
    f = Flower()
    flower = f.get_data(.001)[-1]
    
    return render(request, template_name='home.html', dictionary={'wemo': wemo, 
                                                                  'hue': hue, 
                                                                  'nest': nest,
                                                                  'apex': apex,
                                                                  'roomba': roomba,
                                                                  'flower': flower,
                                                                 })
Esempio n. 14
0
    async def change_prefix(self, message, stripped, server):
        if server is None:
            return

        if stripped:
            old = server.prefix
            stripped += ' '
            server.prefix = stripped[:stripped.find(' ')]

            if len(server.prefix) > 5:
                await message.channel.send(
                    self.get_strings(server)['prefix']['too_long'])
                server.prefix = old

            else:
                await message.channel.send(
                    self.get_strings(server)['prefix']['success'].format(
                        prefix=server.prefix))

        else:
            await message.channel.send(
                self.get_strings(server)['prefix']['no_argument'].format(
                    prefix=server.prefix))

        session.commit()
Esempio n. 15
0
    def __commit(self):
        """
        """
        try:
            handles = [i.handle for i in self.motifs]
            if len(handles) != len(set(handles)):
                pdb.set_trace()

            r = session.query(NR_release).filter(NR_release.id == self.release.id).first()
            if not r:
                session.add(self.release)

            session.add_all(self.motifs)
            session.add_all(self.loops)
            session.add_all(self.history)
            session.add_all(self.intersection)
            session.add_all(self.release_diff)

            session.commit()
            logging.info("Successful update")
        except sqlalchemy.exc.SQLAlchemyError, e:
            logging.error("Update failed. SQLAlchemy error. Rolling back.")
            logging.error(str(e))
            session.rollback()
            self.remove_release(self.release.id)
            sys.exit()
Esempio n. 16
0
def item_form(category=None):
    """ Creates the form for adding new items"""
    if 'username' not in login_session:
        return Page(
            title="Unauthorized",
            contentmain="You are not authorized to see this page.").render()
    if request.method == 'POST':
        new_item = models.Item(name=request.form['name'],
                               description=request.form['description'],
                               user_id=login_session['user_id'],
                               category_id=int(category))
        session.add(new_item)
        session.commit()
        return Page(
            title='Success',
            contentmain=flask.render_template('success.html')).render()
    else:
        category = session.query(models.Category).get(category)
        page = Page(
            title="Create a new category",
            description=
            "This page allows the creation of new categories to the application",
            contentmain=flask.render_template('form_item.html',
                                              category=category))
        return flask.render_template('base.html', page=page)
Esempio n. 17
0
def addNewProduct():
    departments = session.query(Department).all()
    print('\n Department List')
    print('\t Id \t\t Name')
    if departments:
        for department in departments:
            print('\n\t{}\t\t{}'.format(department.id, department.name))
        print("Enter The Product Details")
        print('\n Enter Departement Id')
        departmentId = int(input())
        print("\n Enter Name Of Product")
        name = input()
        print("\n Enter Price Of Product in Rupees")
        price = int(input())
        print("\n Enter Discount on Product only Value")
        discount = int(input())
        print("\n Enter Quantity Of Product")
        count = int(input())
        product = Product(name=name,
                          price=price,
                          discount=discount,
                          count=count,
                          department_id=departmentId)
        session.add(product)
        session.commit()
        print("Succes Fully Added")
    else:
        print("Please Enter Department")
        ADDepartment()
Esempio n. 18
0
def modifyProduct():
    system('cls')
    print("Modify Product")
    displayProducts()
    print("Enter id Of Product To Modify")
    ID = int(input())
    system('cls')
    singleProduct = session.query(Product).filter_by(id=ID)
    while True:
        print('Select To Update')
        print("\n1. Name")
        print("\n2. Quantity")
        print("\n3. Discount")
        print("\n4. Price")
        print("\n5. Department")
        print("\n6. Exit")
        option = int(input())
        if option == 1:
            print("\n Enter Name")
            name = input()
            singleProduct.update({"name": name})
            session.commit()
            print('\n Update Sucessfully')
        if option == 2:
            print("\n Enter Quantity")
            name = int(input())
            singleProduct.update({"count": name})
            session.commit()
            print('\n Update Sucessfully')
        if option == 3:
            print("\n Enter Discount")
            name = int(input())
            singleProduct.update({"discount": name})
            session.commit()
            print('\n Update Sucessfully')
        if option == 4:
            print("\n Enter Price")
            name = int(input())
            singleProduct.update({"price": name})
            session.commit()
            print('\n Update Sucessfully')
        if option == 5:
            print("\n Enter Department")
            departments = session.query(Department).all()
            print('\n Department List')
            print('\t Id \t\t Name')
            if departments:
                for department in departments:
                    print('\n\t{}\t\t{}'.format(department.id,
                                                department.name))
                name = int(input())
                singleProduct.update({"department_id": name})
                session.commit()
                print('\n Update Sucessfully')
            else:
                print("Please Enter Department")
                ADDepartment()
        if option == 6:
            system('cls')
            break
Esempio n. 19
0
def mod():
    global __HEXDIGEST__
    if request.method == "GET":
        mess = session.query(EmailMessage).get(__HEXDIGEST__)
        if mess is None or mess.approved == True:
            flash('No new messages to edit')
            return render_template('edit.html')
        dct = json.loads(mess.everything)
        form = EditForm()
        form.subject.data = dct.get('subject')
        form.text.data = dct.get('body-plain')
        form.approved.data = mess.approved
        return render_template('edit.html', form=form) 
    else:
        form = EditForm(request.form)
        mess = session.query(EmailMessage).get(__HEXDIGEST__)
        if form.approved.data == True:
            send_message(form.data)
            mess.approved = True
            session.add(mess)
            session.commit()
            flash('message sent')
            return render_template('edit.html')
        flash("bad form")
        return "bad form"
Esempio n. 20
0
 def delete(self, account_id, joke_id):
     logger.log(auth.username(), request.date, request.remote_addr,
                request.url)
     authorizer.authorize_user(auth.username(), account_id)
     joke = self.get_joke_or_404(joke_id, account_id)
     session.delete(joke)
     session.commit()
Esempio n. 21
0
def websocket_to_database():
    try:
        websocket = yield from websockets.connect("wss://ws-feed.exchange.coinbase.com")
    except gaierror:
        db_logger.error('socket.gaierror - had a problem connecting to Coinbase feed')
        return
    yield from websocket.send('{"type": "subscribe", "product_id": "BTC-USD"}')
    while True:
        message = yield from websocket.recv()
        if message is None:
            file_logger.error('Websocket message is None!')
            break
        try:
            message = json.loads(message)
        except TypeError:
            db_logger.error('JSON did not load, see ' + str(message))
            continue
        if message['type'] != 'match':
            continue
        new_message = Messages()
        for key in message:
            if hasattr(new_message, key):
                setattr(new_message, key, message[key])
            else:
                db_logger.error(str(key) + ' is missing, see ' + str(message))
                continue
        try:
            session.add(new_message)
            session.commit()
        except IntegrityError:
            session.rollback()
        except DatabaseError:
            file_logger.error('Database Error')
            session.rollback()
Esempio n. 22
0
	def fetchGamelogs(self, player):

		# Delete all gamelogs for player
		for gamelog in player.gamelogs:
			session.delete(gamelog)

		scraper = Scraper()
		logs = scraper.getGamelogs(player.id)
		gamelogs = []
		for log in logs:
			gamelog = Gamelog()
			gamelog.player = player
			gamelog.game_id = log['game_id']
			gamelog.MIN = log['MIN']
			gamelog.FGM = log['FGM']
			gamelog.FGA = log['FGA']
			gamelog.FG_PCT = log['FG_PCT']
			gamelog.FG3M = log['FG3M']
			gamelog.FG3A = log['FG3A']
			gamelog.FG3_PCT = log['FG3_PCT'] 
			gamelog.FG3M = log['FTM']
			gamelog.FG3A = log['FTA']
			gamelog.FG3_PCT = log['FT_PCT'] 
			gamelog.OREB = log['OREB']
			gamelog.DREB = log['DREB']
			gamelog.REB = log['REB'] 
			gamelog.AST = log['AST']
			gamelog.STL = log['STL']
			gamelog.BLK = log['BLK']
			gamelog.TOV = log['TOV']
			gamelog.PTS = log['PTS'] 
			gamelog.DK = self.calcDK(log)
			gamelogs.append(gamelog)
		session.add_all(gamelogs)
		session.commit()
Esempio n. 23
0
def save_game(current_game,user):
	"""	Save a Game State for a particular MxitUser to the database.
	"""
	active_game = session.query(SaveGame).filter_by(user_id=user.id).first()
	#Update the saved game to the new one.
	active_game.game = current_game
	session.commit()
Esempio n. 24
0
def save_utf(utf):
	current_user = session_user(request)
	utf_bool = bool(utf)
	current_user.support_utf8 = utf_bool
	current_user.tested_utf8 = True
	session.commit()
	return redirect(url_for('home'))
Esempio n. 25
0
    def set_info(cls, jid, key, value):
        """ 设置成员选项
        Arguments:
            `jid`   -   jid
            `key`   -   选项键
            `value` -   选项值
        """
        m = cls.get_one(jid)
        try:
            info = session.query(Info).filter(and_(Info.key == key,
                                                   Info.member == m,
                                                   Info.is_global == 0)).one()
            info.value = value
        except NoResultFound:
            info = Info(key, value)
            if m.infos:
                m.infos.append(info)
            else:
                m.infos = [info]
        finally:
            try:
                session.commit()
            except:
                session.rollback()

        return info
Esempio n. 26
0
def create_or_update_account(updated_account):
    existing_account = session \
        .query(Account) \
        .filter_by(google_id=updated_account.google_id) \
        .first()

    if not existing_account:
        try:
            logging.info("Account does not exist in the system!")
            session.add(updated_account)
            session.flush()
            session.commit()

            existing_account = updated_account
        except IntegrityError:
            session.rollback()
            logging.info('User already exists in the system!')

            existing_account = session \
                .query(Account) \
                .filter_by(google_id=updated_account.google_id) \
                .first()

    return {
        'token': jwt_token_utils.create_jwt_token(existing_account)
    }, HTTPStatus.OK
Esempio n. 27
0
def message_good(form):
    global __HEXDIGEST__
    _json = json.dumps(form.to_dict())
    mess = EmailMessage(_json)
    mess.hexdigest = __HEXDIGEST__
    session.add(mess)
    session.commit()
Esempio n. 28
0
    async def get_cmd(self, message):

        data = session.query(RootData).first()
        if data is None:
            data = RootData(prefix='lotto ', prizes=[])
            session.add(data)
            session.commit()

            data = session.query(RootData).first()


        prefix = data.prefix

        command = None

        if message.content == self.user.mention:
            await self.commands['help'](message, '')

        if message.content[0:len(prefix)] == prefix:
            command = message.content[len(prefix):].split(' ')[0]
            stripped = message.content[len(command) + len(prefix):].strip()

        elif message.content[0:len(self.user.mention + ' ')] == self.user.mention + ' ':
            command = message.content[len(self.user.mention + ' '):].split(' ')[0]
            stripped = message.content[len(command) + len(self.user.mention + ' '):].strip()

        if command is not None:
            if command in self.commands.keys():
                await self.commands[command](message, stripped)

                return True

        return False
def guildwars2_filter_cm(comments, array_anet_names):
    for cm in comments:
        logging.info("comment")
        if cm.author.name in array_anet_names:
            logging.info("comment from anet: " + cm.name)
            row = bot_submissions()
            title = cm.link_title
            if (len(title) + len(cm.author.name) + 3) > 300:
                title = title[: 300 - len(cm.author.name) - 3 - 3]
                title += "..."
            row.title = title + " [" + cm.author.name + "]"
            row.type = "link"
            row.subreddit = "gw2devtrack"
            row.submitted = False
            row.content = cm.permalink.replace("//www.reddit.com", "//np.reddit.com") + "?context=1000"
            session.add(row)
        continue  # DISALLOWS COMMENTS TO BE PARSED FPR GW2 LINKS
        if re.search("http.*?:\/\/.*?guildwars2.com\/", cm.body) != None:
            logging.info("comment with gw2 link: " + cm.name)
            all_links = re.findall("http.*?:\/\/.*?guildwars2.com\/[^ \])\s]*", cm.body)
            for link in all_links:
                if link != "":
                    try:
                        prepare_comment(cm.name, False, guildwars2.locate_origin(link))
                    except Exception as e:
                        logging.error(e)
                        session.rollback()
                    else:
                        session.commit()
Esempio n. 30
0
def get_page_links2():
    '''
        Description: get images' second layer links
    '''
    pageLink = page_link1_queue.get()
    print "page links2 process id:%s" %os.getpid()
    print "Starting to crawl : %s" %pageLink
    if pageLink:
        #picture_urls = []  
        response = requests.get(pageLink, headers=headers) 
        soup = BeautifulSoup(response.text, "html.parser")
        picture_divs = soup.find_all("div", {"class":"pic"})
        for picture_div in picture_divs:
            picture_url = picture_div.find("a").get("href")
            page_link2_queue.put(picture_url)
            #picture_urls.append(picture_url)

            query = session.query(SecondLevelLinks)
            query_result = query.filter(SecondLevelLinks.url==picture_url).first()
            if query_result:
                continue
            else:
                second_level_links = SecondLevelLinks(url=picture_url)
                session.add(second_level_links)
        session.flush()
        session.commit()

        return page_link2_queue
    else:
        return None
Esempio n. 31
0
def get_whole_page_content(amount):
	'''
	get_whold_page_content()
	amount : get_page_amount()
	return : write sqlite
	'''
	count = 0
	for page_num in range(1, amount+1):
		print u'Scraping page <%3d>...' % page_num


		url = build_url(page_num)

		print u'Now in: %s' % url

		# get page_content
		content_lst = get_content_from_page(url)

		print u'Get <%3d> pices from this page.\n' % len(content_lst)

		for author, content in content_lst:
			content_obj = Hot(author=author, content=content)
			session.add(content_obj)
			count += 1

		if count >= 100:
			session.commit()
			count = 0

		# couldn't be too soon
		time.sleep(3)

	session.commit()
	return 
Esempio n. 32
0
def ADDepartment():
    system('cls')
    print('Enter Name Of Department')
    name = input()
    departmentName = Department(name=name)
    session.add(departmentName)
    session.commit()
def load_playlists(session):
    user = 1
    playlist_titles = ["Narrative Shorts", "Something Different", "Hellbent Sports", "Documentaries"]
    for title in playlist_titles:
        playlist = models.Playlists(title=title, user_id=user)
        session.add(playlist)
    session.commit()
Esempio n. 34
0
 def post(self, *args, **kwargs):
     user_id = create_user(**kwargs)
     session.commit()
     return {
         'access_token': create_access_token(identity=user_id),
         'refresh_token': create_refresh_token(identity=user_id)
     }
Esempio n. 35
0
    def addEdit(self, _thread_id, _content, _submitted=False):
        existingList = session.query(bot_comments_anetpool).filter_by(
            thread_id=_thread_id).order_by(desc(
                bot_comments_anetpool.edit_id)).first()

        if existingList is None:
            row = bot_comments_anetpool()
            row.thread_id = _thread_id
            _from_template = self.anetpool_template.split('&#009;', 1)
            row.content = _from_template[
                0] + _content + '&#009;' + _from_template[1]
            row.submitted = _submitted
            session.add(row)
        else:
            if (len(existingList.content) + len(_content) >= 10000):
                row = bot_comments_anetpool()
                row.thread_id = _thread_id
                _from_template = self.anetpool_template.split('&#009;', 1)
                row.content = _from_template[
                    0] + _content + '&#009;' + _from_template[1]
                row.submitted_id = 'e' + str(existingList.edit_id)
                row.submitted = _submitted
                session.add(row)
            else:
                _from_save = existingList.content.split('&#009;', 1)
                session.query(bot_comments_anetpool).filter_by(
                    edit_id=existingList.edit_id).update({
                        'content':
                        _from_save[0] + _content + '&#009;' + _from_save[1],
                        'submitted':
                        False
                    })
        session.commit()
Esempio n. 36
0
    def set_online(cls, jid, show=None):
        """ 设置成员在线
        Arguments:
            `jid`   -   成员jid
            `show`  -   stanza.show
        """
        m = cls.get_one(jid)
        if not m:
            return False
        try:
            status = session.query(Status)\
                    .filter(and_(Status.resource == jid.resource,
                                 Status.member == m)).one()
            status.show = show
        except NoResultFound:
            status = Status(show, jid.resource)
            if m.status:
                m.status.append(status)
            else:
                m.status = [status]
        finally:
            try:
                session.commit()
            except:
                session.rollback()

        return True
def delete_category_by_id(category_id):
    """
    HTML endpoint providing a form to delete a category
    """
    if not UserUtils.is_authenticated():
        UserUtils.set_preauthentication_url()
        flash('sign in to delete categories')
        return redirect('/login')

    category = session.query(Category).filter_by(id=category_id).one()

    if not Permissions.get_user_permissions_for_category(category).delete:
        flash('you may delete only empty categories you created')
        return redirect(url_for(
            'get_categories'))

    if request.method == 'POST':
        session.delete(category)
        session.commit()

        flash('category deleted')

        return redirect(url_for(
            'get_categories'))
    else:
        return UserUtils.render_user_template(
            'category_delete.html',
            category=category,
            page_title="%s %s Category" % ("Delete", category.name))
Esempio n. 38
0
def item_edit(category=None, item=None):
    """ Create and process the form for editing an item"""
    if 'username' not in login_session:
        return Page(
            title="Unauthorized",
            contentmain="You are not authorized to see this page.").render()
    category = session.query(models.Category).get(category)
    item = session.query(models.Item).get(item)
    if request.method == 'GET':
        page = Page(
            title="Edit the item " + item.name,
            description=
            "This page allows the creation of new categories to the application",
            contentmain=flask.render_template('form_item.html',
                                              category=category,
                                              item=item))
        return flask.render_template('base.html', page=page)

    if request.method == 'POST':
        item.name = request.form['name']
        item.description = request.form['description']
        session.commit()
        return Page(
            title='Success',
            contentmain=flask.render_template('success.html')).render()
Esempio n. 39
0
File: main.py Progetto: pgsvox/bot
    async def on_message(self, message):

        if message.author.bot or message.content is None:
            return

        u: User = session.query(User).filter(User.user == message.author.id)

        if u.count() < 1:

            user = User(user=message.author.id)

            session.add(user)
            session.commit()

        if message.guild is not None and session.query(Server).filter_by(server=message.guild.id).first() is None:

            server = Server(server=message.guild.id)

            session.add(server)
            session.commit()

        server = None if message.guild is None else session.query(Server).filter(Server.server == message.guild.id).first()
        user = session.query(User).filter(User.user == message.author.id).first()

        try:
            if await self.get_cmd(message, server, user):
                logger.info('Command: ' + message.content)

        except discord.errors.Forbidden:
            try:
                await message.channel.send(ENGLISH_STRINGS.get_string('no_perms_general'))
            except discord.errors.Forbidden:
                logger.info('Twice Forbidden')
Esempio n. 40
0
File: main.py Progetto: robdy/bot
    async def restrict(self, message, stripped, server):

        if not message.author.guild_permissions.manage_guild:
            await message.channel.send(embed=discord.Embed(description=self.get_strings(server, 'admin_required')))

        else:
            disengage_all = True
            args = False

            for role in message.role_mentions:
                args = True
                if role.id not in server.restrictions['data']:
                    disengage_all = False
                server.restrictions['data'].append(role.id)

            if disengage_all and args:
                for role in message.role_mentions:
                    server.restrictions['data'].remove(role.id)
                    server.restrictions['data'].remove(role.id)

                await message.channel.send(embed=discord.Embed(description=self.get_strings(server, 'restrict/disabled')))

            elif args:
                await message.channel.send(embed=discord.Embed(description=self.get_strings(server, 'restrict/enabled')))

            elif stripped:
                await message.channel.send(embed=discord.Embed(description=self.get_strings(server, 'restrict/help')))

            else:
                await message.channel.send(embed=discord.Embed(description=self.get_strings(server, 'restrict/allowed').format(' '.join(['<@&' + str(i) + '>' for i in server.restrictions['data']]))))

        session.commit()
Esempio n. 41
0
File: main.py Progetto: pgsvox/bot
    async def set_timezone(self, message, stripped, prefs):

        if message.guild is not None and message.author.guild_permissions.manage_guild:
            s = 'timezone/set'
            admin = True
        else:
            s = 'timezone/set_p'
            admin = False

        if stripped == '':
            await message.channel.send(embed=discord.Embed(description=prefs.language.get_string('timezone/no_argument').format(prefix=prefs.prefix, timezone=prefs.timezone)))

        else:
            if stripped not in pytz.all_timezones:
                await message.channel.send(embed=discord.Embed(description=prefs.language.get_string('timezone/no_timezone')))
            else:
                if admin:
                    prefs.server_timezone = stripped
                else:
                    prefs.timezone = stripped

                d = datetime.now(pytz.timezone(stripped))

                await message.channel.send(embed=discord.Embed(description=prefs.language.get_string(s).format(timezone=stripped, time=d.strftime('%H:%M:%S'))))

                session.commit()
Esempio n. 42
0
def stats(bot, update):
    if "Haro" in update.message.text and "?" in update.message.text:
        update.message.reply_text('Haro figyel! Haro figyel!')

    user = User(
        update.message.from_user.id,
        update.message.from_user.first_name,
        update.message.from_user.last_name,
        update.message.from_user.username
    )
    user = session.merge(user)
    session.add(user)

    chat = Chat(
        update.message.chat_id,
        update.message.chat.title if update.message.chat.title else update.message.chat.type,
    )
    chat = session.merge(chat)
    session.add(chat)

    user_activity = UserActivity(
        user,
        chat,
        update.message.date
    )
    session.add(user_activity)
    session.commit()
Esempio n. 43
0
File: main.py Progetto: pgsvox/bot
    async def restrict(self, message, stripped, server):

        disengage_all = True
        args = False

        all_roles = [x.role for x in session.query(RoleRestrict).filter(RoleRestrict.server == message.guild.id)]

        for role in message.role_mentions:
            args = True
            if role.id not in all_roles:
                disengage_all = False
                r = RoleRestrict(role=role.id, server=message.guild.id)
                session.add(r)

        if disengage_all and args:
            roles = [x.id for x in message.role_mentions]
            session.query(RoleRestrict).filter(RoleRestrict.role.in_(roles)).delete(synchronize_session='fetch')

            await message.channel.send(embed=discord.Embed(description=server.language.get_string('restrict/disabled')))

        elif args:
            await message.channel.send(embed=discord.Embed(description=server.language.get_string('restrict/enabled')))

        elif stripped:
            await message.channel.send(embed=discord.Embed(description=server.language.get_string('restrict/help')))

        else:
            await message.channel.send(embed=discord.Embed(description=server.language.get_string('restrict/allowed').format(' '.join(['<@&{}>'.format(i) for i in all_roles]))))

        session.commit()
Esempio n. 44
0
def save_sitemap(url_object):
    url = url_object.get("value")
    headers = {'User-Agent': BaseConfig.UA}
    r = requests.get(url, headers=headers)
    soup = BeautifulSoup(r.text, 'html.parser')
    urls = soup.find_all("url")
    for url in urls:
        if not url.loc:
            raise ValueError("url.loc is None...")

        parse_result = urllib.parse.urlparse(url.loc.text)
        sitemap = session.query(Sitemap).filter(Sitemap.loc == urllib.parse.unquote(url.loc.text)).first()

        if sitemap is None:
            sitemap = Sitemap()
            sitemap.loc = urllib.parse.unquote(url.loc.text)
            sitemap.lastmod = strptime(url.lastmod.text) if url.lastmod else None
            sitemap.change_freq = url.changefreq.text if url.changefreq else None
            sitemap.priority = Decimal(url.priority.text) if url.priority else None
            sitemap.domain = parse_result.netloc
            sitemap.path = urllib.parse.unquote(parse_result.path)
            sitemap.status = SitemapTaskStatus.before_html_stats
            session.add(sitemap)
        elif sitemap.lastmod is None or sitemap.lastmod > strptime(url.lastmod.text) if url.lastmod else None :
            sitemap.lastmod = strptime(url.lastmod.text) if url.lastmod else None
            sitemap.status = SitemapTaskStatus.before_html_stats
            session.merge(sitemap)
        session.flush()

    session.commit()
Esempio n. 45
0
def pay_credit(credit_id):
    found_credit = session.query(Credit).filter(
        Credit.id == credit_id).one_or_none()
    if found_credit is None:
        raise ValidationError(message='Credit does not exist')
    if found_credit.fk_client_id != current_identity.id:
        return 'Access denied', 403
    data = request.json
    validation_schema = CreditSchema()
    got_data = {'sum_pay': data['sum_pay']}
    try:
        validation_schema.load(got_data)
    except ValidationError as err:
        return err.messages, 400
    if found_credit.sum_left <= 0:
        raise ValidationError(message='Credit paid off')
    found_credit.sum_pay = got_data['sum_pay']
    found_credit.month_paid += 1
    found_credit.sum_paid += int(found_credit.sum_pay)
    found_credit.sum_left = found_credit.sum_take - found_credit.sum_paid
    if found_credit.sum_left <= 0: found_credit.pay_off = True
    budget = session.query(Budget).filter(
        Budget.available_sum.isnot(None)).one_or_none()
    budget.available_sum += int(found_credit.sum_pay)
    session.commit()
    return_schema = CreditSchema()
    return_credit = return_schema.dump(found_credit)
    return return_credit
Esempio n. 46
0
def get_course_offering(course, count, end):
    fields = ['course_id', 'term', 'crn', 'section', 'pass_nopass',
              'instructor', 'day_time', 'location', 'campus', 'c_type',
              'status', 'cap', 'current', 'available', 'wl_cap', 'wl_current',
              'wl_available', 'section_title', 'fees', 'restrictions',
              'comments']

    html = urllib2.urlopen(course.url).read()
    soup = BeautifulSoup(html)

    table = soup.find(id='ctl00_ContentPlaceHolder1_SOCListUC1_gvOfferings')
    if not table:
        # No course offerings found for that course.
        return

    trs = table.find_all('tr')[1:]
    print ('Downloading %d Course Offerings for: %s %s %s (%s) (%d/%d)' %
            (len(trs), course.tag, course.num, course.title, course.credits,
             count, end))

    for tr in trs:
        elems = tr.find_all('font')
        # Get rid of 'Credits' field.
        del elems[3]
        elem_vals = [course.id] + [elem.text for elem in elems]
        mapped_fields = dict(map(get_co_type, zip(fields, elem_vals)))
        course_offering = CourseOffering(**mapped_fields)
        session.add(course_offering)
        session.commit()
Esempio n. 47
0
def category_delete(category=None):
    """ Delete a category.

    If the value of action is all, every item associated to the category will also be deleted.
    """
    if 'username' not in login_session:
        return Page(
            title="Unauthorized",
            contentmain="You are not authorized to see this page.").render()
    category = session.query(models.Category).get(category)
    if request.method == 'GET':
        return Page(title="Delete category " + category.name,
                    description="Deletion page for category " + category.name,
                    contentmain=flask.render_template(
                        'category_delete.html', category=category)).render()
    if request.method == 'POST':
        deleted = []
        if request.form['action'] == 'all':
            for i in category.load_items():
                deleted.append(i.name)
                session.delete(i)
        session.delete(category)
        session.commit()
        return Page(
            title="Category "+category.name+" was deleted",
            contentmain="The category was completely removed, including the following items: "+\
            ", ".join([i for i in deleted])+".").render()
Esempio n. 48
0
def get_page_links1(webUrl):
    '''
        Description: get images' first layer links
    '''
    init_db()
    htmlContent = requests.get(webUrl, headers=headers)
    soup = BeautifulSoup(htmlContent.text, "html.parser")
    wp_page_numbers_div = soup.find("div", {"id":"wp_page_numbers"})
    endPageTag = wp_page_numbers_div.find_all("a")[-1]
    endPageLink = endPageTag.get('href')
    if endPageLink: 
        regex = r"(\D+\d+\D+)(\d+)(\D+)"
        m = re.match(regex, endPageLink)
        if m:
            pageNumber = int(m.groups()[1])  #get page number
            for index in xrange(1, pageNumber+1):
                pageLink = "%s"*4 %(webUrl, m.group(1), index, m.group(3))
                #pageLinks.append(pageLink)
                page_link1_queue.put(pageLink)
                query = session.query(FirstLevelLinks)
                query_result = query.filter(FirstLevelLinks.url==pageLink).first()
                if query_result:
                    continue 
                else:
                    first_level_links = FirstLevelLinks(url=pageLink)
                    session.add(first_level_links)
            session.flush()
            session.commit()
            return page_link1_queue
        else:
            return None
Esempio n. 49
0
    async def deletes(self):
        await self.wait_until_ready()

        while not self.is_closed():

            try:
                dels = []

                for d in session.query(Deletes).filter(
                        Deletes.time <= time.time()):
                    dels.append(d.map_id)

                    message = await self.get_channel(d.channel
                                                     ).get_message(d.message)

                    if message is None or message.pinned:
                        pass
                    else:
                        logger.info(
                            '{}: Attempting to auto-delete a message...'.
                            format(datetime.utcnow().strftime('%H:%M:%S')))
                        try:
                            await message.delete()
                        except Exception as e:
                            logger.error('Ln 1049: {}'.format(e))

            except Exception as e:
                logger.error('check_reminders: {}'.format(e))

            if len(dels) > 0:
                session.query(Deletes).filter(Deletes.map_id.in_(dels)).delete(
                    synchronize_session='fetch')

            session.commit()
            await asyncio.sleep(1)
Esempio n. 50
0
    async def on_message(self, message):

        clears = session.query(Autoclears).filter(
            Autoclears.channel == message.channel.id).order_by(Autoclears.time)

        for c in clears:
            if c.user == message.author.id or c.user is None:
                d = Deletes(time=time.time() + c.time,
                            channel=message.channel.id,
                            message=message.id)

                session.add(d)
                session.commit()
                break

        if message.author.bot or message.content is None or message.guild is None:
            return

        try:
            if await self.get_cmd(message):
                logger.info('Command: ' + message.content)
                session.commit()

        except discord.errors.Forbidden:
            try:
                await message.channel.send('No permissions to perform actions.'
                                           )
            except discord.errors.Forbidden:
                logger.info('Twice Forbidden')
Esempio n. 51
0
def register():
    username = request.form.get("username")[0:10]
    pwd = request.form.get("pwd")
    code = request.form.get("code")
    valid_codes = session.query(models.Code).filter(
        models.Code.expire_date - getTimeOClockOfToday() <= 3600 * 48)
    list_code = []
    for valid in valid_codes:
        list_code.append(valid.code)
    if code not in list_code:
        print("验证码已过期/错误")
        return render_template('success.html', content="注册码已过期/错误")
    else:
        for valid in valid_codes:
            if code == valid.code:
                if valid.is_register != 1:
                    all_users = session.query(models.Users.name).all()
                    list_user = []
                    for user in all_users:
                        list_user.append(user.name)
                    if username not in list_user:
                        session.add(models.Users(name=username, password=pwd))
                        session.query(models.Code).filter(
                            models.Code.code == code).update(
                                {"is_register": 1})
                        session.commit()
                        return render_template('success.html', content="注册成功")
                    else:
                        return render_template('success.html',
                                               content="用户名已存在")
                else:
                    return render_template('success.html', content="验证码已注册")
Esempio n. 52
0
    def addBasePokemonToUser(self, addRequestDict):
        try:
            userId = addRequestDict.get("userId")
            pokedexId = addRequestDict.get("pokedexId")

            pokemon = self.pokemonService.getPokemonByPokedexId(pokedexId)
            if pokemon is None:
                raise Exception("Pokemon with pokedexId:" + str(pokedexId) +
                                " was not found!")

            userPokemon = UserPokemon()
            userPokemon.userId = userId
            userPokemon.pokedexId = pokedexId
            userPokemon.name = pokemon.name
            userPokemon.nickname = addRequestDict.get("nickname", pokemon.name)
            userPokemon.height = pokemon.height
            userPokemon.sprites = pokemon.sprites
            userPokemon.weight = pokemon.weight
            userPokemon.hunger = sysConst.MAX_HUNGER
            userPokemon.maxHp = pokemon.hp
            userPokemon.currentHp = pokemon.hp
            userPokemon.attack = pokemon.attack
            userPokemon.defense = pokemon.defense
            userPokemon.specialAttack = pokemon.specialAttack
            userPokemon.specialDefense = pokemon.specialDefense
            userPokemon.speed = pokemon.speed
            userPokemon.healthState = sysConst.ALIVE_POKEMON_STATE

            session.add(userPokemon)
            session.flush()
            session.commit()
            return userPokemon.id
        except Exception as e:
            session.rollback()
            raise e
Esempio n. 53
0
    def __import_interactions_from_csv(self, ifn, pdb_file):
        """Reads the csv file, imports all interactions, deletes the file when
           done to avoid stale data and free up disk space"""
        logging.info('Importing interactions')
        commit_every = 1000
        reader = csv.reader(open(ifn, 'rb'), delimiter=',', quotechar='"')
        for i,row in enumerate(reader):
            I = PairwiseInteractions(iPdbSig=row[0], jPdbSig=row[1])
            I.pdb_id = pdb_file
            I.f_crossing = int(row[3])
            interaction = row[2].strip()
            if interaction[0] == 's' or interaction[0:2] == 'ns':
                I.f_stacks = interaction
            elif interaction[-2:] == 'BR':
                I.f_brbs = interaction
            elif interaction[-3:] == 'BPh':
                I.f_bphs = interaction
            else:
                I.f_lwbp = interaction

            session.merge(I)
            """Since the files can be huge, it's unfeasible to store all
            objects in memory, have to commit regularly"""
            if i % commit_every == 0:
                session.commit()
        session.commit()
        os.remove(ifn)
        logging.info('Csv file successfully imported')
Esempio n. 54
0
def login_code():
    def get_x_code(x):
        letter = string.ascii_letters
        digit = string.digits
        code = letter + digit
        data = random.choices(code, k=x)
        str_data = ''
        for i in data:
            str_data += i
        return str_data

    code_count = session.query(
        models.Code).filter(models.Code.expire_date -
                            getTimeOClockOfToday() <= 3600 * 24 * 2).count()
    if code_count < 10:
        code = get_x_code(4)
        session.add(
            models.Code(code=code,
                        expire_date=int(time.time()) + 60 * 60 * 24,
                        is_register=0))
        session.commit()
        print(code)
        return render_template("code_page.html", code="恭喜你获得注册码:" + code)
    else:
        return render_template("code_page.html", code="今天验证码已经发放完毕")
Esempio n. 55
0
def get_contents(soup):
    # 获取job info
    results = soup.select('.con_list_item')
    for result in results:
        content = result.attrs
        experience, education = result.select('.li_b_l')[0].get_text().replace(
            ' ', '').strip().split('/')
        tag = result.select('.li_b_l')[1].get_text()
        positionname = content.get('data-positionname')
        positionid = content.get('data-positionid')
        companyid = content.get('data-positionid')
        salary = content.get('data-salary')
        s_salary, e_salary = split_salary(salary)
        company = content.get('data-company')
        area = result.select('.add')[0].find('em').get_text()
        job = Job(positionname=positionname,
                  positionid=positionid,
                  companyid=companyid,
                  s_salary=s_salary,
                  e_salary=e_salary,
                  company=company,
                  status=0,
                  area=area,
                  experience=experience,
                  education=education,
                  tag=tag)
        session.add(job)
        message = "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}".format(
            positionname, positionid, companyid, s_salary, e_salary, company,
            area, experience, education, tag)
        logger.info(message)
    session.commit()
Esempio n. 56
0
def load_baskets(session):
	user = 1
	basket_names = ["Example 1"]
	for name in basket_names:
		name = models.Baskets(name=name)
		session.add(name)
	session.commit()
Esempio n. 57
0
async def subscribe(request):
    schema = SubscribeSchema()
    data, error = schema.load(request.form)  # todo 传入空的字符串不能required不能识别
    if error:
        for key, value in error.items():
            error[key] = key + ':' + ','.join(value)
        return resp_error(';'.join(error.values()))

    subscriber = Subscriber()
    subscriber.nick_name = data['nick_name']
    subscriber.email = data['email']
    subscriber.resources = data['resources']
    session.add(subscriber)
    try:
        session.commit()
        session.close()
    except Exception as e:
        session.rollback()
        session.close()
        return resp_error(e.args)
    email_ = await init_email(data['nick_name'], data['email'],
                              data['resources'])
    if not email_:
        return resp_ok('您已经成功订阅')
    else:
        return resp_error(email_)
Esempio n. 58
0
    def synchronize(studio):
        """
        Effectue une synchronisation pour la playlist donnée.
        
        La synchronisation consiste à mettre en correspondance les 
        informations stockées dans la playlist et les éléments contenus
        dans Liquidsoap.
        """

        if not liq.is_connected:
            return

        playlist = studio.jukebox

        if playlist is None:
            return

        # Getting info from Liquidsoap

        for element in playlist.elements_pending:
            if element.media and element.will_end_at and element.will_end_at < time.time() and \
               element.status != u"done":
                element.mark_as_done()
                studio.mark_as_changed()

        rawnumeros = liq.send_command("request.on_air")
        numeros = rawnumeros.split(' ')
        for rid in numeros:
            metadatas = liq.parse_metadatas(liq.send_command("request.metadata " + str(int(float(rid)))))
            if 'sydroid_uid' in metadatas.keys():
                element = playlist.element_by_uid(int(metadatas['sydroid_uid']))
                if element is not None and 'on_air' in metadatas.keys():
                    newonair = liq.parse_date(metadatas['on_air'])
                    if element.on_air_since != newonair:
                        element.on_air_since = newonair
                        session.add(element)
                        studio.mark_as_changed()
                    if element.will_end_at > time.time() and element.status != "playing":
                        element.status = "playing"
                        session.add(element)
                        studio.mark_as_changed()
                    elif element.will_end_at <= time.time() and element.status != "done":
                        element.mark_as_done()
                        session.add(element)
                        studio.mark_as_changed()

        if (playlist.current_element is not None and playlist.current_element.status == "done") or \
                (playlist.current_element is None and playlist.elements_to_play.count() > 0):
        #            if playlist.current_element is None:
        #                sylog("DEBUG: No current element for curpos = %d," % playlist.curpos)
        #            else:
        #                sylog("DEBUG: Current element (pos=%d) is done,"  % playlist.curpos)

            playlist.curpos += 1
            #            sylog("DEBUG: CURPOS UP ! (from %d to %d)" % (playlist.curpos - 1, playlist.curpos))
            studio.mark_as_changed()

        session.add(studio)
        session.commit()
Esempio n. 59
0
def load_basket_entries(session):
	with open ('baskets.csv', 'rU') as f:
		filename_stores = csv.reader(f, delimiter=",")
		for basketname_row in filename_stores:
			new_basketname_row = models.Basket_Entry(food_id=basketname_row[1], basket_id=basketname_row[2])
			session.add(new_basketname_row)
		session.commit()
		session.refresh(new_basketname_row)
Esempio n. 60
0
 def mark_pdb_as_analyzed(self, pdb_id, column_name):
     """
     """
     P = PdbAnalysisStatus(id = pdb_id)
     setattr(P,column_name.lower(),datetime.datetime.now())
     session.merge(P)
     session.commit()
     logging.info('Updated %s status for pdb %s', column_name, pdb_id)