Exemplo n.º 1
0
def main():
    ps = passwordsafe.PasswordSafe()
    SessionMaker = ps.connect_with_config("members")
    session = SessionMaker()

    groups = session.query(Group).all()

    print("Generating mailing lists for:")

    thisyear = str(datetime.now().year)[-2:]

    listdir = "lists"
    if not os.path.exists(listdir):
        os.mkdir(listdir)
        print("Created lists directory")

    elif os.path.isfile(listdir):
        print("Error: lists is a file. Exiting...")
        return

    for group in groups:
        if group.abbreviation_fld != None:
            print(group.name_fld)
            mailinglist = open(os.path.join(listdir, group.abbreviation_fld +
                thisyear), "w")
            mailinglist.write("# " + group.name_fld + " generated " +
                    date.today().isoformat())
            for membership in group.memberships:
                if (membership.isCurrent() and membership.member):
                    mailinglist.write("\n# %s\n%s" %
                            (membership.member.getWholeName(),
                                membership.member.contactinfo.email_fld))
Exemplo n.º 2
0
def main():
    app = QApplication(sys.argv)

    # Initialize SvakSvat
    ps = passwordsafe.PasswordSafe(enablegui=True)
    SessionMaker = scoped_session(ps.connect_with_config("members"))
    ss = SvakSvat(SessionMaker)
    ss.show()

    return app.exec_()
Exemplo n.º 3
0
def main():
    ps = passwordsafe.PasswordSafe()
    SessionMaker = ps.connect_with_config("mimer")
    session = SessionMaker()

    groups = session.query(Group).filter(Group.name_fld == "Styrelsen")

    with open("test.csv", "w") as f:
        for group in groups:
            for membership in group.memberships:
                f.write(
                    str(membership.startTime_fld.date().year) + "\t" +
                    membership.member.getName() + "\t" +
                    membership.member.contactinfo.email_fld + "\n")
Exemplo n.º 4
0
def main():
    ps = passwordsafe.PasswordSafe()
    SessionMaker = ps.connect_with_config("mimer")
    session = SessionMaker()
    writer = csv.writer(open("alltut.csv", "w"))

    #members = [m for m in session.query(Member).all() if not m.membershipmemberships]
    #print ("all members without memberships: ", len(members))

    members = common.get_members_with_membership(session, "Ordinarie medlem",
                                                 False, True).all()
    print("member length without ordinarie medlem: ", len(members))

    members += common.get_members_with_membership(session, "Ordinarie medlem",
                                                  True, True).all()
    print("member length after noncurrent ordinarie medlem: ", len(members))

    members = common.get_members_with_membership(session, "Ordinarie medlem",
                                                 True, False).all()
    print("Ordinarie medlemmar: ", len(members))

    members = session.query(Member).all()
    print("All members: ", len(members))

    header = [
        "första år samt medlemskapstyp", "StälMstart",
        "Nuvarande medlemskapstyp"
    ] + [x.__str__().split('.')[1] for x in Member.__table__.columns]
    header += [
        x.__str__().split('.')[1] for x in ContactInformation.__table__.columns
    ]
    header += ["grupper", "poster", "medlemskap"]
    writer.writerow(header)

    counter = 0
    for member in members:
        dump_member(member, writer)
        counter += 1
        if counter % 50 == 0:
            print(int((counter / len(members)) * 100), "%")

    print("All done. Kill me if I wont quit...")
    return
    """
Exemplo n.º 5
0
def main():
    ps = passwordsafe.PasswordSafe()
    SessionMaker = ps.connect_with_config("mimer")
    session = SessionMaker()
    writer = csv.writer(open("meritlist.csv", "w"))
    members = session.query(Member).order_by(Member.surName_fld).all()
    for member in members:
        for membership in member.membershipmemberships:
            mship = membership.membership
            currentmembership = ""
            if membership.isCurrent():
                currentmembership += mship.name_fld + " "

        if member.notes_fld:
            writer.writerow([
                currentmembership,
                member.getWholeName(), "Hedersbetygelser:", member.notes_fld
            ])
        for groupmembership in member.groupmemberships:
            if groupmembership.startTime_fld and groupmembership.endTime_fld:
                group = groupmembership.group
                for year in range(groupmembership.startTime_fld.date().year,
                                  groupmembership.endTime_fld.date().year + 1):
                    writer.writerow([
                        currentmembership,
                        member.getWholeName(), group.name_fld, year
                    ])
        for postmembership in member.postmemberships:
            if postmembership.startTime_fld and postmembership.endTime_fld:
                post = postmembership.post
                for year in range(postmembership.startTime_fld.date().year,
                                  postmembership.endTime_fld.date().year + 1):
                    writer.writerow([
                        currentmembership,
                        member.getWholeName(), post.name_fld, year
                    ])
    print("I am all done, kill me please.")
    sys.exit(0)
Exemplo n.º 6
0
    def __init__(self, dry_run=False):
        # Set environment variable for LDAP to accept self signed certs
        os.environ["LDAPTLS_REQCERT"] = "never"

        self.dry_run = dry_run

        self.ldapmodifypath = which("ldapmodify")
        self.ldapsearchpath = which("ldapsearch")
        self.ldappasswdpath = which("ldappasswd")
        self.ldapdeletepath = which("ldapdelete")

        self.ps = passwordsafe.PasswordSafe(enablegui=True)
        self.ldaphost = self.ps.get_config_value("ldap", "host")
        auth, self.servicelogin, self.servicepassword = self.ps.askcredentials(
            self.check_ldap_login, "ldap", "servicelogin")

        SessionMaker = self.ps.connect_with_config("pykota")
        self.pykotasession = SessionMaker()

        self.LDAPMODIFY_CMD = shlex.split(
            """%s -H \
            %s -xD cn=%s,dc=teknologforeningen,dc=fi -w %s""" %
            (self.ldapmodifypath, self.ldaphost, self.servicelogin,
             self.servicepassword))
Exemplo n.º 7
0
import common

# constants
# exception classes
# interface functions
# classes
# internal functions & classes


def main(session):
    ordinarie = common.get_members_with_membership(session, "Ordinarie medlem",
                                                   True)
    for member in ordinarie:
        member.subscribedtomodulen_fld = 0

    print("dirty count:", len(session.dirty))

    if input("Are you sure [y/n]? ") == "y":
        print("Committing...")
        session.commit()
        return
    print("Rolling back changes")


if __name__ == '__main__':
    ps = passwordsafe.PasswordSafe()
    SessionMaker = ps.connect_with_config("members")
    session = SessionMaker()
    status = main(session)
    sys.exit(status)
Exemplo n.º 8
0
def main():
    ps = passwordsafe.PasswordSafe()
    SessionMaker = ps.connect_with_config("members")
    session = SessionMaker()

    ignoreKatalogen = False

    print("Detta script get ut adresser/info i csv format.")
    print("Alternativ:")
    print("1. Modulen")
    print(" -Lista för alla som Modulen skall skickas till")
    print("2. StÄlMar")
    print(" -Lista på alla stämar")
    print("3. Ordinarie")
    print(" -Lista på alla Ordinarie")
    print("4. Julkort")
    print(" -Vem skall få julkort?")
    print("5. Katalogen-lista-Stalm")
    print(" -Lista på alla stälmar, utom dom som inte vill ge ut info")
    print("6. Katalogen-lista-ordinarie")
    print(" -Lista på alla ordinarie, utom dom som inte vill ge ut info\n")
    print("Du får välja om du vill ha address, eller all info sedan.")


    choice = input("Ange siffra:\n")

    if choice[0] == "1":
        print("Modulen vald")
        filename = "modulenadresser.csv"
        members = get_modulenaddresses(session)
    elif choice[0] == "2":
        print("StÄlMar valda")
        filename = "stalmar.csv"
        members = get_stalmar(session)
    elif choice[0] == "3":
        print("Ordinarie valda")
        filename = "ordinarie.csv"
        members = get_ordinarie(session)

    elif choice[0] == "4":
        print("Julkort vald")
        filename = "julkortadresser.csv"
        members = get_christmascardaddressess(session)

    elif choice[0] == "5":
        print("Katalogen-lista-stalm vald")
        filename = "katalogen-lista-stalm.csv"
        members = get_katalogenlist_stalm(session)
        ignoreKatalogen = True

    elif choice[0] == "6":
        print("katalogen-lista-ordinarie vald")
        filename = "katalogen-lista-ordinarie.csv"
        members = get_katalogenlist_ordinarie(session)
        ignoreKatalogen = True  

    print("Oppnar fil.")
    writer = csv.writer(open(filename, "w"))

    choice = "2"
    choice = input("Vill du ha all info(1) eller kontaktuppgifter(2)?[2]")
    if choice[0] == "1":
        print("All info vald")
        print("Skriver fil: %s/%s" % (os.getcwd(), filename))
        for member in members:
            writer.writerow(get_allinfo_tuple(member))
    else:
        print("Endast adresser valda")
        print("Skriver fil: %s/%s" % (os.getcwd(), filename))
        for member in members:
            writer.writerow(get_contactinfo_tuple(member, ignoreKatalogen))

    print("Fardig")

    """