예제 #1
0
def overview():
    """ Overview and tool update of all languages supported!"""
    # Update the list of languages allowed on the site, 
    # except for the language used by your users at that time.
    if request.method == 'POST':
        lan_object = Languages()
        data = lan_object.update()
        message = lan_object.message
        status = lan_object.status
    
    # Gets documents from the collections of all languages 
    languages_list = g.languages_object.get_languages(1)
    language_chosen = g.languages_object.get_languages(2)
    return render_template( '{}/index.html'.format(MODULE_DIR), **locals())
예제 #2
0
def core_before_request():
    """
    - To run before each request
    - It's save variable db in the global variable "g"
    """
    g.db = db
    g.my = None
    g.languages_object = Languages()
    # Get all the available languages
    # e.g. {u'en': u'English', u'it': u'Italiano'}
    g.available_languages = g.languages_object.get_languages(0)
    get_headers()

    # Check that user has login
    if 'user_id' in session:
        # get user_id from session
        user_id = session['user_id']
        # get the user's personal data.
        my = g.db.users.find_one({'_id': ObjectId(user_id)})

        # If user_id not exist in the user list g.my is None
        if my:
            g.my = my
            if not "token" in g.my:
                g.my['token'] = get_token(CLIENT_ID, CLIENT_SECRET,
                                          user['username'], user['password'])
                g.db.users.update({"_id": g.my["_id"]}, user)
            # get user language
            g.lan = g.my['lan']
            g.language = g.available_languages[g.lan]
            if my['rank'] < 80:
                get_hash_admin()
예제 #3
0
def index():
    """ 
    Overview and tool update of all languages supported!
    """
    # Update the list of languages allowed on the site, 
    # except for the language used by your users at that time.
    if request.method == 'POST':
        lan_object = Languages()
        lan_object.update()
        message = lan_object.message
        status = lan_object.status
    
    # Gets documents from the collections of all languages 
    languages_list = g.languages_object.all_lang
    language_chosen = g.languages_object.get_all_lang_by_code(g.lang)
    return render_template( '{}/index.html'.format(MODULE_DIR), **locals())
예제 #4
0
def getUpdatesFromPackage(aFiles, aDate):

    updates = []
    versions = Versions()
    types = Types()
    languages = Languages()
    date = core.dates.toString(aDate)

    for updateFile in aFiles:

        path = os.path.normpath(updateFile)
        kb = core.kb.getKB(updateFile)
        osVersion = versions.getVersion(updateFile)
        osType = types.getType(updateFile)
        language = languages.getLanguage(updateFile)

        updates.append(json.dumps({'Path': path,
                                   'KB': kb,
                                   'Version': osVersion,
                                   'Type': osType,
                                   'Language': language,
                                   'Date': date}))

    return updates
예제 #5
0
def fromPath(aPath):

    folders = os.listdir(aPath)
    updates = []

    for folder in folders:
        path = os.path.join(aPath, folder)
        try:
            updates.extend(fromPathAndDate(path, folder))
        except:
            date = datetime.datetime.now()
            date = core.dates.toString(date)
            updates.append(json.dumps({'Path': folder,
                                       'KB': core.kb.getKB(folder),
                                       'Version': Versions().getVersion(folder),
                                       'Type': Types().getType(folder),
                                       'Language': Languages().getLanguage(folder),
                                       'Date': date}))

    return updates
예제 #6
0
def updates4Target(aStorage, aVersion, aPlatform, aLanguage, aPathToReport):

    KBs = core.kb.getKBsFromReportFile(
        aPathToReport) if None != aPathToReport else None
    version = Versions().getVersion('{0}{1}{0}'.format(
        os.sep, aVersion.replace(' ', '')))
    platform = Types().getType('{0}{1}{0}'.format(os.sep, aPlatform))
    language = Languages().getLanguage('{0}{1}{0}'.format(os.sep, aLanguage))

    query = {}
    if None != KBs and KBs != []:
        query['KB'] = KBs
    if not isinstance(version, dict):
        query['Version'] = version
    if not isinstance(platform, dict):
        query['Type'] = platform
    if not isinstance(language, dict):
        query['Language'] = language

    updates = aStorage.get(query)
    Updates.sortByFieldUpToDown(updates, 'Path')

    return (updates, version, platform, language, KBs)
예제 #7
0
파일: before.py 프로젝트: imfht/flaskapps
def core_before_request():
    """ Run before each request.
    - It's save variable db in the global variable "g"

    """
    g.my = None
    g.languages_object = Languages()
    # Get all the available languages
    # e.g. {u'en': u'English', u'it': u'Italiano'}
    g.available_languages = g.languages_object.available_lang
    get_headers()
    g.all_the_languages = g.languages_object.all_lang_by_tuple
    user_id = session.get('user_id', None)
    # Check that user has login
    if user_id:
        # get the user's personal data.
        my = model.users.find(user_id=user_id, my_id=user_id)
        # If user_id not exist in the user list g.my is None
        if my and my['status'] > NOTACTIVATED:
            g.my = my
            # get user language
            g.lang = g.my.get('lan', 'en')
            g.language = g.available_languages[g.lang]
예제 #8
0
파일: pages.py 프로젝트: zchking/bombolone
import re
from flask import Blueprint, g
from bson import ObjectId

# Imports inside bombolone
import model.pages
from core.utils import ensure_objectid
from decorators import check_rank, get_hash
from core.languages import Languages
from core.validators import CheckValue

MODULE_DIR = 'modules/pages'
pages = Blueprint('pages', __name__)

check = CheckValue()  # Check Value class
languages_object = Languages()


class Pages(object):
    """ This class allows to :
    - get_page
    - reset
    - new
    - remove
    """

    page = {}
    type_label = {}
    len_of_label = 0

    message = None  # Error or succcess message
예제 #9
0
import os
import sys
import core.dirs
from core.storage import Uif
from core.types import Types
from core.updates import Updates
from core.versions import Versions
from core.languages import Languages

versions = Versions()
types = Types()
languages = Languages()

versions.mVersions['WindowsXP'] = versions.WinXP
versions.mVersions['WindowsServer2003'] = versions.Win2k3
versions.mVersions['Windows6.0'] = versions.Vista
versions.mVersions['Windows6.1'] = versions.Seven
versions.mVersions['Windows8-RT'] = versions.Eight
versions.mVersions['Windows8.1'] = versions.EightDotOne

types.mTypes['x86'] = types.x86
types.mTypes['x64'] = types.x64
types.mTypes['arm'] = types.ARM
types.mTypes['ia64'] = types.IA64

languages.mLanguages = {}
languages.mLanguages['NEU'] = languages.Neutral
languages.mLanguages['ARA'] = languages.Arabic
languages.mLanguages['CHS'] = languages.Chinese_Simplified
languages.mLanguages['CHT'] = languages.Chinese_Traditional
languages.mLanguages['CSY'] = languages.Czech
예제 #10
0
 def lang(self) -> Languages:
     if self._lang is None:
         self._lang = Languages(self)
     return self._lang
예제 #11
0
import os
import sys
import core.dirs
from core.storage import Uif
from core.types import Types
from core.updates import Updates
from core.versions import Versions
from core.languages import Languages

versions = Versions()
types = Types()
languages = Languages()

versions.mVersions['WindowsXP'] = versions.WinXP
versions.mVersions['WindowsServer2003'] = versions.Win2k3
versions.mVersions['Windows6.0'] = versions.Vista
versions.mVersions['Windows6.1'] = versions.Seven
versions.mVersions['Windows8-RT'] = versions.Eight
versions.mVersions['Windows8.1'] = versions.EightDotOne

types.mTypes['x86'] = types.x86
types.mTypes['x64'] = types.x64
types.mTypes['arm'] = types.ARM
types.mTypes['ia64'] = types.IA64

languages.mLanguages = {}
languages.mLanguages['NEU'] = languages.Neutral
languages.mLanguages['ARA'] = languages.Arabic
languages.mLanguages['CHS'] = languages.Chinese_Simplified
languages.mLanguages['CHT'] = languages.Chinese_Traditional
languages.mLanguages['CSY'] = languages.Czech