def get_perm_num(data_dir=CONFIG.data_dir): app_system_perm_file = CONFIG.app_system_perm_file app_perm_file = _(data_dir, app_system_perm_file) with open(app_perm_file, 'r') as f: app_perms = json.load(f) perms = set() for app, perm in app_perms.items(): perms.update(perm) return len(perms)
def load_dataset_raw(data_dir=CONFIG.data_dir, app_api_file="app_apis.json", app_perm_file="app_system_permissions.json"): with open(_(data_dir, app_api_file), 'r') as f: app_apis = json.load(f) with open(_(data_dir, app_perm_file), 'r') as f: app_perms = json.load(f) app_dict = {} for app in app_apis.keys(): # use at least one api, require at least one permission and have readme file if (app in app_perms) and app_apis[app] and app_perms[app]: app_dict[app] = { 'apis': app_apis[app], 'perms': app_perms[app], } dataset = Dataset(app_dict) return dataset
def unit(report, path, report_file): """Run unit tests for extension at path""" path = pathlib.Path(path) path = install(path) options = [ _(BASIC_PATH, 'vendor/bin/phpunit'), '--configuration', _(BASIC_PATH, 'dev/tests/unit/phpunit.xml.dist') ] if report_file: options += ['--log-%s' % report, report_file] proc = subprocess.Popen(options + [_(path, 'Test/Unit')]) proc.communicate() if not report_file: exit(proc.returncode) exit(proc.returncode)
def eqp(severity, report, path, report_file): """Run EQP tests for path""" proc = subprocess.Popen([ _('/magento-coding-standard', 'vendor/bin/phpcs'), path, '--standard=Magento2', '--severity=' + str(severity), '--extensions=php,phtml', '--report=' + report ], stdout=subprocess.PIPE) stdout, stderr = proc.communicate() if report_file: with open(report_file, 'wb') as fp: fp.write(stdout) else: click.echo(stdout) exit(proc.returncode)
from django.core.management.base import BaseCommand import xlrd from calling.models import UserModel, CampaignModel from os.path import dirname as _ ,join DATA_DIR = join(_(_(_(_(__file__)))),'contact_files') class Command(BaseCommand): def handle(self,*args, **options): self.populate_contacts() #self.populate_campaigns() def populate_contacts(self): file_name = join(DATA_DIR,'contacts.xlsx') book=xlrd.open_workbook(file_name) sheet=book.sheet_by_name('sheet1') start_index = 1 end_index = sheet.nrows while start_index < end_index: name = sheet.cell_value(rowx=start_index, colx=0) number = sheet.cell_value(rowx=start_index, colx=1) campaign = sheet.cell_value(rowx=start_index, colx=2) print name,int(number) UserModel.objects.create(name=name,number=int(number),callStatus="To be called",campaign=campaign)
from distutils.core import setup from os.path import join as _ from os import getcwd import py2exe PATH = getcwd() DATA = [('database', [_(PATH, 'database', 'FICT_timetable.db')]), ('', [_(PATH, 'easy_weeks.log'), _(PATH, 'README.md'), _(PATH, 'User_manual.pdf')]), (_('database', 'start_db'), [_(PATH, 'database', 'start_db', 'teachers.json'), _(PATH, 'database', 'start_db', 'groups.json'), _(PATH, 'database', 'start_db', 'departments.json'), _(PATH, 'database', 'start_db', 'departments_2.json'), _(PATH, 'database', 'start_db', 'departments_def.json'), _(PATH, 'database', 'start_db', 'teachers_all.json'), _(PATH, 'database', 'start_db', 'seeds.json')])] setup( windows=['main_file.py'], data_files=DATA, options={ 'py2exe': { 'packages': ['database', 'gui', 'sqlalchemy'], 'includes': ['sip', 'cffi'], 'excludes': ['email'], # 'bundle_files': 2, 'skip_archive': 1 } } )
import os from os.path import dirname as _ import random import json if __name__ == '__main__': base_dir = _(os.path.abspath(__file__)) secret_dir = os.path.join(base_dir, 'secret') os.makedirs(secret_dir, exist_ok=True) data = dict() data['SECRET_KEY'] = ''.join([ random.SystemRandom().choice( 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for _ in range(50) ]) data['ADMIN_EMAIL'] = input('ADMIN_EMAIL: ') data['ADMIN_PASSWORD'] = input('ADMIN_PASSWORD: '******'DB_ENGINE (mysql, sqlite3) : ') data["DB_ENGINE"] = "django.db.backends.{}".format(DB_ENGINE) print('Using DB_ENGINE as {}'.format(data["DB_ENGINE"])) if DB_ENGINE == 'sqlite3': data["DB_NAME"] = input('DB_NAME (ex: db.sqlite3):') else: data["DB_NAME"] = input('DB_NAME: ') data["DB_USER"] = input('DB_USER: '******'DB_PASSWORD: '******'DB_HOST: ')