def __init__(self, dbPath, dbName): self.database = dbPath + dbName self.dataPath = dbPath self.visits = Visits() self.guests = Guests() self.reports = Reports(self) self.teams = Teams() self.accounts = Accounts() self.devices = Devices() self.unlocks = Unlocks() # needs path since it will open read only self.customReports = CustomReports(self.database) self.certifications = Certifications() self.members = Members() self.logEvents = LogEvents() if not os.path.exists(self.database): if not os.path.exists(dbPath): os.mkdir(dbPath) with self.dbConnect() as c: self.migrate(c, 0) else: with self.dbConnect() as c: data = c.execute('PRAGMA schema_version').fetchone() if data[0] != SCHEMA_VERSION: self.migrate(c, data[0])
def makeNewMember(All_Users): global FILE print(All_Users) M = Members() print(M) All_Users += [M] saveData(All_Users)
def sale(): shop_list = [] tel = raw_input("输入你的手机号码:") disc = Members.get_disc_by_tell(tel) while True: #输入商品,Q退出输入 price = scilt.input_price() if price == "Q": break else: #保存商品的单价 shop_list.append(price) new_pay_list = scilt.pay_list_cal(shop_list, disc) out_msg = scilt.out_way(new_pay_list) print out_msg
def generateLink(self, namespace: str, member: Optional[Member] = None) -> str: def identifierToPath(identifierList: Sequence[str]) -> str: path = os.path.join(self.path, os.path.join(*[self.toFileName(name) for name in identifierList])) if self.curDir: path = os.path.relpath(path, self.curDir) return path # Create the identifier identifier = Members.makeIdentifier(namespace, member.getName() if member else "") identifierList = identifier.split("::") if self.members.getMemberGroup(identifier): return os.path.join(identifierToPath(identifierList), "index.md") name = identifierList.pop() return os.path.join(identifierToPath(identifierList), "index.md")
def main(): try: # Get pods ip address ipaddr = socket.gethostbyname(socket.gethostname()) print('main: POD IP {}'.format(ipaddr)) config.load_incluster_config() kube = KubeHandler() mongo = MongoHandler(kube) members = Members(mongo.db) mongo.setMembers(members) watcher = Watcher(kube, mongo, members, ipaddr) watcher.Start() except KeyboardInterrupt: pass except Exception as error: print('main: ERROR - {}'.format(error)) finally: print("main: SHUTDOWN") sys.exit(0)
from users import Users from members import Members from team import Team import smugmug USER_NAME = "*****@*****.**" TEAM_NAME = "ftc16072" PASSWORD = "******" membersList = [ "Andrew", "Chirag", "Eric", "Izaak", "Nithya", "Philip", "Preeti", "Rishi", "Arjun", "Ryan", "Nikhil" ] albumDict = { '2019-04-01': '/api/v2/album/VgQcSw', '2020-03-01': '/api/v2/album/2z78cj' } if __name__ == "__main__": users = Users() members = Members() team = Team(TEAM_NAME) users.add(USER_NAME, TEAM_NAME, PASSWORD) user = users.getUser(USER_NAME, PASSWORD) with user.team.dbConnect() as connection: members.createTable(connection) members.insertMembers(connection, membersList) smugmug.createTable(connection) for date, album in albumDict: smugmug.addEntry(connection, date, album)
app = Flask(__name__) app.config.from_object('beerapp.settings') db = SQLAlchemy(app) gravatar = Gravatar(app, size=120, rating='x', default='retro', force_default=False, force_lower=False) paginator = Paginator(app) from members import Members members = Members(app) app.jinja_env.filters['br_month'] = br_month_filter from posts import BlogPost from feed_generator import FeedGenerator def TAGS(): _TAGS = [] members_str = open(app.config['MEMBERS_FILE']).read() for member in yaml.load_all(members_str): if member.get('tags'): for tag in member['tags'].split(","): _TAGS.append(tag.strip())
return TaskStages.workingOn if __name__ == "__main__": DB_STRING = os.path.join(os.path.dirname(__file__), 'data/database.sqlite3') try: os.remove(DB_STRING) except IOError: pass #delete File, if it doesn't exist we don't care with sqlite3.connect(DB_STRING) as connection: tasks = Tasks() members = Members() entries = Entries() smugmugConfig = json.load(open('secrets.json', 'r')) #Create the Tables tasks.createTable(connection) members.createTable(connection) entries.createTable(connection) #Initate our Members Table membersList = [ "Andrew Vo", "Chirag Sreedhara", "Eric Wong", "Evan Spiering", "Izaak Kreykes", "Nithya Golla", "Philip Smith", "Preeti Thirukonda", "Rishi Maroju" ] members.insertMembers(connection, membersList)
% e) sys.exit(2) if __name__ == '__main__': parser = ArgumentParser() parser.add_argument("--file", default="mongodb_members_16_nov.csv", help="Input file") args = parser.parse_args() mdb = MUGAlyserMongoDB("mongodb://localhost") members = Members(mdb, get_meetup_key()).collection() audit = Audit(mdb).collection() count = 0 notFoundCount = 0 foundCount = 0 csvmembers = {} lastBatchID = Audit(mdb).getLastBatchID() print("Processing batch ID: %i" % lastBatchID) with open(args.file, "rb") as csvdata: with open("csvfile.out", "w") as csvout: reader = csv.DictReader(csvdata, delimiter=",") for r in reader: #print( r ) count = count + 1
def __init__(self): self.tasks = Tasks() self.members = Members() self.SCHEMA_VERSION = SCHEMA_VERSION
class Entries(): def __init__(self): self.tasks = Tasks() self.members = Members() self.SCHEMA_VERSION = SCHEMA_VERSION def createTable(self, dbConnection): dbConnection.execute(""" CREATE TABLE Entries( id INTEGER PRIMARY KEY, date TEXT NOT NULL, task_id INTEGER NOT NULL, member_id INTEGER NOT NULL, hours REAL, accomplished TEXT, why TEXT, learned TEXT, notes TEXT, diagramDot TEXT, next_steps TEXT, photo_link TEXT, imgKey TEXT)""") self.tasks.createTable(dbConnection) self.members.createTable(dbConnection) dbConnection.execute('PRAGMA schema_version = ' + str(SCHEMA_VERSION)) def addEntry(self, dbConnection, date, taskId, memberId, hours, accomplished, why, learned, nextSteps, notes, diagramDot, photo, smugmugConfig): dbConnection.execute( "Insert INTO Entries (date, task_id, member_id, hours,accomplished, why, learned, next_steps, notes, diagramDot, imgKey) VALUES (?,?,?,?,?,?,?,?,?,?,?)", (date, taskId, memberId, hours, accomplished, why, learned, nextSteps, notes, diagramDot, photo)) def migrate(self, dbConnection, dbSchemaVersion): if dbSchemaVersion > SCHEMA_VERSION: raise Exception("Unknown DB schema version" + str(dbSchemaVersion)) if dbSchemaVersion < 4: dbConnection.execute("ALTER TABLE Entries ADD why TEXT") if dbSchemaVersion < 5: dbConnection.execute("ALTER TABLE Entries ADD notes TEXT") if dbSchemaVersion < 6: dbConnection.execute("ALTER TABLE Entries ADD diagramDot TEXT") if dbSchemaVersion < 8: dbConnection.execute("ALTER TABLE Entries ADD hours REAL ") self.tasks.migrate(dbConnection, dbSchemaVersion) self.members.migrate(dbConnection, dbSchemaVersion) dbConnection.execute('PRAGMA schema_version = ' + str(SCHEMA_VERSION)) def getDateList(self, dbConnection): dateList = [] for row in dbConnection.execute( "SELECT DISTINCT date FROM Entries ORDER BY date DESC"): dateList.append(row[0]) return dateList def getPrevNext(self, dbConnection, dateString): dateList = self.getDateList(dbConnection) i = dateList.index(dateString) if i == len(dateList) - 1: prev = "" else: prev = dateList[i + 1] if i == 0: next = "" else: next = dateList[i - 1] return (prev, next) def updateSmugmugLink(self, dbConnection, smugmugConfig, entryID, imgKey): photoLink = smugmug.get_medium_link(imgKey, smugmugConfig) dbConnection.execute( """ UPDATE Entries SET photo_link = ? WHERE id = ? """, (photoLink, entryID)) return photoLink def getDateTasksDictionary(self, dateStr, dbConnection, smugmugConfig): entryDict = {} for row in dbConnection.execute( """ SELECT tasks.name, members.name, accomplished, why, learned, next_steps, notes, diagramDot, photo_link, imgkey, Entries.id, hours FROM Entries INNER JOIN tasks ON Entries.task_id = Tasks.id INNER JOIN members ON Entries.member_id = Members.id WHERE (date = ?) """, (dateStr, )): taskName = row[0] memberName = row[1] accomplished = row[2] why = row[3] learned = row[4] next_steps = row[5] notes = row[6] diagramDot = row[7] photoLink = row[8] imgKey = row[9] entriesId = row[10] hours = row[11] if not (photoLink): if imgKey: photoLink = self.updateSmugmugLink(dbConnection, smugmugConfig, entriesId, imgKey) newEntry = Entry(dateStr, taskName, memberName, hours, accomplished, why, learned, next_steps, notes, diagramDot, photoLink, imgKey) if not (row[0] in entryDict.keys()): entryDict[row[0]] = [newEntry] else: entryDict[row[0]].append(newEntry) return entryDict def getEntriesWithHours(self, dbConnection): entries = [] for row in dbConnection.execute( """ SELECT tasks.name, members.name, date, hours FROM Entries INNER JOIN tasks ON Entries.task_id = Tasks.id INNER JOIN members ON Entries.member_id = Members.id WHERE (hours > 0) ORDER BY date ASC """, ()): entries.append( Entry(date=row[2], taskName=row[0], memberName=row[1], hours=row[3], accomplished="", why="", learned="", nextSteps="", notes="", diagramDot="", photoLink="", imgKey="")) return entries def getDateDictionary(self, taskId, dbConnection, smugmugConfig): entryDict = {} taskName = "" for row in dbConnection.execute( """ SELECT tasks.name, members.name, accomplished, photo_link, imgkey, Entries.id, date, why, notes, diagramDot FROM Entries INNER JOIN tasks ON Entries.task_id = Tasks.id INNER JOIN members ON Entries.member_id = Members.id WHERE (Tasks.id = ?) ORDER BY date ASC """, (taskId, )): taskName = row[0] photoLink = row[3] imgKey = row[4] if not (photoLink): if imgKey: photoLink = self.updateSmugmugLink(dbConnection, smugmugConfig, row[5], imgKey) newEntry = Entry(date=row[6], taskName=taskName, memberName=row[1], hours=0, accomplished=row[2], learned="", nextSteps="", photoLink=photoLink, imgKey=imgKey, why=row[7], notes=row[8], diagramDot=row[9]) if not (row[6] in entryDict.keys()): entryDict[row[6]] = [newEntry] else: entryDict[row[6]].append(newEntry) return (entryDict, taskName)
view_func=Display.as_view('display_pictures'), methods=["GET", "POST"]) app.add_url_rule('/videos/', view_func=Videos.as_view('videos'), methods=["GET", "POST"]) app.add_url_rule('/display_videos/', view_func=vidDisplay.as_view('display_videos'), methods=["GET", "POST"]) app.add_url_rule('/contact/', view_func=Contact.as_view('contact'), methods=["GET", "POST"]) app.add_url_rule('/donate/', view_func=Sponsors.as_view('support'), methods=["GET"]) app.add_url_rule('/members/', view_func=Members.as_view('members'), methods=["GET", "POST"]) app.add_url_rule('/events/', view_func=Event.as_view('events'), methods=["GET", "POST"]) @app.errorhandler(404) def page_not_found(error): return flask.render_template('404.html'), 404 app.debug = True if __name__ == "__main__": init_db() init_db_members() init_db_events() app.run()
from render.markdown import MarkdownRender from parser.doxygen import DoxygenParser if __name__ == "__main__": parser = argparse.ArgumentParser(description="Generate documentation from Doxygen XML output") parser.add_argument('--doxygen', dest="doxygen", default="docs/xml", help="Doxygen XML output directory") parser.add_argument("-o", "--output", dest="output", default="docs/md", help="Output of the generate documentation") args = parser.parse_args() doxygen = DoxygenParser() # Add all xml files to the parser fileList = glob.glob("{}/**/*".format(args.doxygen), recursive=True) for fileName in fileList: if fileName.lower().endswith(".xml"): try: root = ET.parse(fileName).getroot() doxygen.parse(root) except Exception as e: print("file: %s" % (fileName)) raise e data = doxygen.getMembersData() members = Members(data) # Render to markdown render = MarkdownRender(args.output, members) render.process()
import time from flask import render_template from flask import Response from team import app from members import Members from whereabouts import Whereabouts from photos import Photos team = Members().load(app.config['TEAM_TSV_URL']) whereabouts = Whereabouts(app.config['WHEREABOUTS_TSV_URL']) photos = Photos(app.config['PHOTO_URL'], username=app.config.get('PHOTO_USERNAME', ''), password=app.config.get('PHOTO_PASSWORD', '')) @app.route('/') def _home(): return render_template('index.html') @app.route('/cards') def _cards(): return render_template('cards.html', members=team.members) @app.route('/whereabouts') def _whereabouts_today():
def __init__(self): self._people = People() self._groups = Groups() self._members = Members(self._people, self._groups)
class AddressBook(object): """ Address Book containing people, groups and members It offers APIs for storing, retreiving and searching people and groups """ def __init__(self): self._people = People() self._groups = Groups() self._members = Members(self._people, self._groups) def addPerson(self, firstName, lastName, emailAddresses, phoneNumbers): """ Add person to phone book :param firstName: First name of the person :param lastName: Last name of the person :param emailAddresses: List of email addresses :param phoneNumbers: List of phone numbers :return: A dictionary of person :exception If the person with same first name and last name already exists :exception If the email and phone number is not a list """ return self._people.addPerson(firstName, lastName, emailAddresses, phoneNumbers) def addGroup(self, name): """ Add group to address book :param name: Name of the group :return: Name of the group :exception: if the group already exists """ return self._groups.addGroup(name) def addMember(self, groupName, personFirstName, personLastName): """ Add a person to group :param groupName: Group name :param personFirstName: First name of person :param personLastName: Last name of person :return: True if saved, Flase otherwise """ return self._members.addMember(groupName, personFirstName, personLastName) def getGroupMembers(self, groupName): """ Get the list of group members :param groupName: Name of the group :return: None if invalid group, else list of people in the group """ group = self._groups.getGroup(groupName) if group: peopleKeys = self._members.findPeople(group) people = [self._people.findPerson(person) for person in peopleKeys] return people return None def getGroups(self, firstName, lastName): """ Get the list of groups :param firstName: First name of the person :param lastName: Last name of the person :return: List of group names else None if person does not exist """ person = self._people.findPerson(firstName + lastName) if person: group = self._members.findGroups(person['firstName'] + person['lastName']) return group return None def findPersonByName(self, **kwargs): """ Find the person by name :param kwargs: firstName, lastName or both :return: list of people found """ return self._people.findPeople(**kwargs) def findPersonByEmail(self, emailAddress): """ Find the person by email :param emailAddress: Email address :return: List of people with the given email address """ firstNameLastNameList = self._people.findByEmail(emailAddress) return [self._people.findPerson(p) for p in firstNameLastNameList]
class Engine(object): def __init__(self, dbPath, dbName): self.database = dbPath + dbName self.dataPath = dbPath self.visits = Visits() self.guests = Guests() self.reports = Reports(self) self.teams = Teams() self.accounts = Accounts() self.devices = Devices() self.unlocks = Unlocks() # needs path since it will open read only self.customReports = CustomReports(self.database) self.certifications = Certifications() self.members = Members() self.logEvents = LogEvents() if not os.path.exists(self.database): if not os.path.exists(dbPath): os.mkdir(dbPath) with self.dbConnect() as c: self.migrate(c, 0) else: with self.dbConnect() as c: data = c.execute('PRAGMA schema_version').fetchone() if data[0] != SCHEMA_VERSION: self.migrate(c, data[0]) def dbConnect(self): return sqlite3.connect(self.database, detect_types=sqlite3.PARSE_DECLTYPES) def migrate(self, dbConnection, db_schema_version): if db_schema_version < SCHEMA_VERSION: self.visits.migrate(dbConnection, db_schema_version) self.members.migrate(dbConnection, db_schema_version) self.guests.migrate(dbConnection, db_schema_version) self.teams.migrate(dbConnection, db_schema_version) self.customReports.migrate(dbConnection, db_schema_version) self.certifications.migrate(dbConnection, db_schema_version) self.accounts.migrate(dbConnection, db_schema_version) self.devices.migrate(dbConnection, db_schema_version) self.unlocks.migrate(dbConnection, db_schema_version) self.logEvents.migrate(dbConnection, db_schema_version) dbConnection.execute('PRAGMA schema_version = ' + str(SCHEMA_VERSION)) elif db_schema_version != SCHEMA_VERSION: # pragma: no cover raise Exception("Unknown DB schema version" + str(db_schema_version) + ": " + self.database) def injectData(self, dictValues): areas = { "visits": self.visits, "members": self.members, "guests": self.guests, "teams": self.teams, "customReports": self.customReports, "certifications": self.certifications, "accounts": self.accounts, "devices": self.devices, "unlocks": self.unlocks, "logEvents": self.logEvents } for (key, member) in areas.items(): if key in dictValues: with self.dbConnect() as dbConnection: member.injectData(dbConnection, dictValues[key]) def getGuestLists(self, dbConnection): all_guests = self.guests.getList(dbConnection) building_guests = self.reports.guestsInBuilding(dbConnection) guests_not_here = [ guest for guest in all_guests if guest not in building_guests ] return (building_guests, guests_not_here)