示例#1
0
 def _checkAndApplyChanges(orig, other):
     if 'source' in other:
         source = other.pop('source')
         other.pop('md5Hash', None)
         newHash = getMd5(getMd5(source))
         if orig.md5Hash != newHash:
             orig.source = source
             orig.md5Hash = newHash
     for attr, value in six.iteritems(other):
         setattr(orig, attr, value)
示例#2
0
                orig.md5Hash = newHash
        for attr, value in six.iteritems(other):
            setattr(orig, attr, value)

if __name__ == '__main__':
    set_connection_settings(db=7)
    isProject = False
    if isProject:
        a = {'md5Hash': '998889', 'source': 'xxx', 'startUrl': ''}
        pm = ProjectManager('')
        print(pm.createProject(a))
        print(pm.getAllProjects())
        ps = list(pm._projects.keys())
        print(pm._projects)

        # print('-->Ps:{}'.format(ps))
        # print(pm.deleteProject(ps[0], delay=None))
    else:
        # task = Task(url='http://www.baidu.com')
        # print(task.save())
        taskList = Task.query.filter().all()
        taskList[0].md5Hash = getMd5(taskList[0].url)
        taskList[0].save()
        print(taskList[0].to_dict())
        pm = ProjectManager('')
        ps = pm.getAllProjects()[0]
        print(ps)
        print('project: {}'.format(ps.to_dict()))
        print(pm.updateProject(ps.id, tasks=[taskList[0]]))
        print(pm.getProjects([27], True))