Beispiel #1
0
def import_one(folder) :
  
    print ('%s, %s, %s, %s, %s' % (folder['title'], folder['mainparentuid'], folder['mainparenttype'], folder['parentuid'], folder['parenttype'])).encode('utf-8')
    if reverse.has_key(folder['mainparentuid']) :
        mainpar = folder['mainparentuid']
        print ("main parent: (%s,%s)" % (e_type(mainpar),title(mainpar))).encode('utf-8')
        if title(mainpar) != 'RESOURCES' :
            print title(mainpar).encode('utf-8')

        path  = []
        tags = []
        main = get_top_container(folder['uid'],path,tags)
        print (','.join(path)).encode('utf-8')
        print (','.join(['%s'% t for t in tags])).encode('utf-8')

        if main.__class__ == User :
            container = TgGroup.objects.get(group_name='resources')
            creator = main
            f_name=make_file_name(folder['id'],folder['uid']) 

            try :
                create_resource(container, creator, folder['id'], f_name, folder, tags)
            except Exception, e:
                print e
                import ipdb
                ipdb.set_trace()
                log.append(folder['uid'])

        elif main.__class__ == TgGroup :
            print "((()))",tags
            container = main
            creator_uid= folder['creatoruid']
            try:
                creator = get_user_for(creator_uid)
            except:
                print "No user corresponds to %s" % creator_uid
                print maps[creator_uid]

                creator = get_admin_user()
                print creator
                ipdb.set_trace()

            site_hosts = get_all_members_group().get_admin_group()
            if not creator.is_member_of(site_hosts) :
                site_hosts.add_member(creator)
                flag = True
            else :
                flag = False

            f_name = make_file_name(folder['id'],folder['uid'])
            try :
                create_resource(container, creator, folder['id'], f_name, folder, tags)
            except Exception, e :
                print e
                import ipdb
                ipdb.set_trace()
                log.append(folder['uid'])

            if flag :
                site_hosts.remove_member(creator)
Beispiel #2
0
def import_all(all) :
    for file in all :
        match = get_matching_id(file)

        if match :
            print "found %s " % file['title'].encode('utf-8')
        else :
            try:
                print "trouble with %s" % file['title']
            except :
                print "trouble with %s (unicode)" % file['title'].encode('utf-8')
            #ipdb.set_trace()
            try :
                print
                import_one(file)
                if reverse.has_key(file['parentuid']) :
                    par = file['parentuid']
                    print ("parent: (%s,%s)" % (e_type(par),title(par))).encode('utf-8')
            except Exception, e:
                print e
                ipdb.set_trace()
                log.append('%s, %s, %s'%(file['uid'],file['title'],e))
Beispiel #3
0
def import_all(all):
    for file in all:
        match = get_matching_id(file)

        if match:
            print "found %s " % file['title'].encode('utf-8')
        else:
            try:
                print "trouble with %s" % file['title']
            except:
                print "trouble with %s (unicode)" % file['title'].encode(
                    'utf-8')
            #ipdb.set_trace()
            try:
                print
                import_one(file)
                if reverse.has_key(file['parentuid']):
                    par = file['parentuid']
                    print("parent: (%s,%s)" %
                          (e_type(par), title(par))).encode('utf-8')
            except Exception, e:
                print e
                ipdb.set_trace()
                log.append('%s, %s, %s' % (file['uid'], file['title'], e))
Beispiel #4
0
def import_one(folder):

    print('%s, %s, %s, %s, %s' %
          (folder['title'], folder['mainparentuid'], folder['mainparenttype'],
           folder['parentuid'], folder['parenttype'])).encode('utf-8')
    if reverse.has_key(folder['mainparentuid']):
        mainpar = folder['mainparentuid']
        print("main parent: (%s,%s)" %
              (e_type(mainpar), title(mainpar))).encode('utf-8')
        if title(mainpar) != 'RESOURCES':
            print title(mainpar).encode('utf-8')

        path = []
        tags = []
        main = get_top_container(folder['uid'], path, tags)
        print(','.join(path)).encode('utf-8')
        print(','.join(['%s' % t for t in tags])).encode('utf-8')

        if main.__class__ == User:
            container = TgGroup.objects.get(group_name='resources')
            creator = main
            f_name = make_file_name(folder['id'], folder['uid'])

            try:
                create_resource(container, creator, folder['id'], f_name,
                                folder, tags)
            except Exception, e:
                print e
                import ipdb
                ipdb.set_trace()
                log.append(folder['uid'])

        elif main.__class__ == TgGroup:
            print "((()))", tags
            container = main
            creator_uid = folder['creatoruid']
            try:
                creator = get_user_for(creator_uid)
            except:
                print "No user corresponds to %s" % creator_uid
                print maps[creator_uid]

                creator = get_admin_user()
                print creator
                ipdb.set_trace()

            site_hosts = get_all_members_group().get_admin_group()
            if not creator.is_member_of(site_hosts):
                site_hosts.add_member(creator)
                flag = True
            else:
                flag = False

            f_name = make_file_name(folder['id'], folder['uid'])
            try:
                create_resource(container, creator, folder['id'], f_name,
                                folder, tags)
            except Exception, e:
                print e
                import ipdb
                ipdb.set_trace()
                log.append(folder['uid'])

            if flag:
                site_hosts.remove_member(creator)
Beispiel #5
0
load_all()

good = []
bad = []

for group in maps['groups']:
    print group['groupname'], group['uid']

for folder in maps['folders']:
    parent_uid = folder['mainparentuid']
    print
    print folder['title'], parent_uid

    print folder.keys()
    print folder['mainparenttype']
    if reverse.has_key(parent_uid):
        parent_type = reverse[parent_uid][0]
        if parent_type == 'groups':
            parent_group = reverse[parent_uid][1]
            print parent_type, parent_group['groupname']
            print "_)))", folder['children']
            top = get_top_container(folder['parentuid'])
            creator = get_creator(folder)

            for key, val in folder['children'].iteritems():
                print key, val
                if '.' in val:
                    f_name = '%s.%s' % (key, val.split('.', 1)[1])
                    print "Filename %s" % f_name
                    if create_resource(top, creator, val, f_name, folder):
                        good.append((top, creator, f_name))
Beispiel #6
0

good = []
bad = []

for group in maps['groups'] :
    print group['groupname'],group['uid']

for folder in maps['folders'] :
    parent_uid = folder['mainparentuid']
    print 
    print folder['title'], parent_uid
    
    print folder.keys()
    print folder['mainparenttype']
    if reverse.has_key(parent_uid) :
        parent_type = reverse[parent_uid][0]
        if parent_type == 'groups' :
            parent_group = reverse[parent_uid][1]
            print parent_type, parent_group['groupname']
            print "_)))",folder['children']
            top = get_top_container(folder['parentuid'])
            creator = get_creator(folder)

            for key,val in folder['children'].iteritems() :
                print key, val
                if '.' in val :
                    f_name = '%s.%s' % (key, val.split('.',1)[1])
                    print "Filename %s"%f_name
                    if create_resource(top, creator, val, f_name, folder) :
                        good.append((top,creator,f_name))
Beispiel #7
0
userlog = []
if __name__ == '__main__' :
    load_all()
    for upload in maps['File'] :
        print 
        uid = upload['uid']
        title = upload['title']
        related = upload['related']        
            
        container = get_top_container(uid,[],[])
        
        print container, title.encode('utf-8'), related
        
        mainparentuid =  upload['mainparentuid']
        if reverse.has_key(mainparentuid) :
            print "mainparent %s, %s" % (e_type(mainparentuid),e_title(mainparentuid))
            mainparent = reverse[mainparentuid]
            try :
                if mainparent[1]['groupname'] != 'RESOURCES' :
                    print "Main parent title %s" % mainparent[1]['groupname']
            except Exception, e :
                print e
                if e_type(mainparentuid) == 'User' :
                    userlog.append({'uid':uid,'mainparentuid':mainparentuid,'owner':e_title(mainparentuid)})
                else :
                    print e
                    ipdb.set_trace()
                
        else :
            print "no reverse for %s" % uid