Ejemplo n.º 1
0
    def collect_copy_data(self,device_profile):

        flag=0
        print "collect_copy_data called"
        destination=device_profile['destination_directory']
        create_dir = ["Documents","Images","Audio","Video","Others"]
        if set(os.listdir(destination)).issuperset(set(create_dir)):
            pass
            
        else:
            flag=1
            print destination
            format_dirs=[]
            for each in create_dir:
                a=os.path.join(destination,each).replace('/','\\')
                format_dirs.append(a)
                os.mkdir(a)
                print "dirs made"
                #os.mkdir(os.path.join(destination,'/',each))
            print "called"
            format_dirs=[ each.replace('\\','/') for each in format_dirs]
            print format_dirs
            print flag
            path_list.file_list(self.sync_folder_list)
            folder_path_to_be_copied=path_list.android_side_dictionary.values()
            for each in folder_path_to_be_copied:
                file_extension=os.path.splitext(each)[-1]
                print file_extension
                
                if file_extension in ['.MP3', '.WMA', '.WAV', '.MP2', '.AAC', '.AC3', '.AU', '.OGG', '.FLAC']:
                    each = '/' + each
                    cmd = "pull %s %s"%(each,format_dirs[2])
                    #print cmd
                    B.call_adb(cmd)
                    #a.pull(each,format_dirs[2])
                elif file_extension in ['.jpg','.png','.JPG','.PNG']:
                    #print "jpg reached"
                    each = '/' + each
                    cmd = "pull %s %s"%(each,format_dirs[1])
                    B.call_adb(cmd)
                    #a.pull(each,format_dirs[1])
                elif file_extension in ['.pdf','.docx','.doc','.xls','.sh','.PDF']:
                    each = '/' + each
                    cmd = "pull %s %s"%(each,format_dirs[0])
                    B.call_adb(cmd)
Ejemplo n.º 2
0
    def collect_copy_data(self,device_profile):

        flag=0  
        print "collect_copy_data called"
        destination=device_profile['destination_directory']
        create_dir = ["Documents","Images","Audio","Video","Others"]
        if set(os.listdir(destination)).issuperset(set(create_dir)):
            

            path_list.get_file_list_from_destination(destination)
            wn = path_list.windows_side_dictionary
            wn_keys =wn.keys()
            path_list.file_list(self.sync_folder_list)
            an = path_list.android_side_dictionary
            an_keys = an.keys()
            print len(wn_keys)
            print len(an_keys)
            #list_to_be_copied = list(set(list1)-set(list2))
            list_to_be_copied = []
            for each in list2 :
                if each not in list1:
                    list_to_be_copied.append(each)
            print len(list_to_be_copied)
            print list_to_be_copied

            for each in list_to_be_copied:
                file_extension=os.path.splitext(each)[-1]
                print file_extension
                                
                if file_extension in ['.MP3', '.WMA', '.WAV', '.MP2', '.AAC', '.AC3', '.AU', '.OGG', '.FLAC']:
                    #each = '/' + each
                    cmd = "pull %s %s"%(each,format_dirs[2])
                    #print cmd
                    B.call_adb(cmd)
                    #a.pull(each,format_dirs[2])
                elif file_extension in ['.jpg','.png','.JPG','.PNG']:
                    #print "jpg reached"
                    #each = '/' + each
                    cmd = "pull %s %s"%(each,format_dirs[1])
                    B.call_adb(cmd)
                    #a.pull(each,format_dirs[1])
                elif file_extension in ['.pdf','.docx','.doc','.xls','.sh','.PDF']:
                    #each = '/' + each
                    cmd = "pull %s %s"%(each,format_dirs[0])
                    B.call_adb(cmd)

                elif file_extension in ['.mkv','.flv','.mp4','.avi']:
                    cmd = "pull %s %s"%(each,format_dirs[3])
                    B.call_adb(cmd)
                else:
                    cmd = "pull %s %s"%(each,format_dirs[4])
                    B.call_adb(cmd)
                    #a.pull(each,format_dirs[0]

            #print list1
            # for each in path_list.android_side_dictionary.items() :
            #     print each
            # #print list2
            #print list_to_be_copied

            # for each in list_to_be_copied:
            #     print each
            
        else:
            flag=1
            print destination
            format_dirs=[]
            for each in create_dir:
                a=os.path.join(destination,each).replace('/','\\')
                format_dirs.append(a)
                try:
                    os.mkdir(a)
                    print "dirs made"
                except:
                    pass
                #os.mkdir(os.path.join(destination,'/',each))
            print "called"
            format_dirs=[ each.replace('\\','/') for each in format_dirs]
            print format_dirs
            print "flag"
            path_list.file_list(self.sync_folder_list)
            an = path_list.android_side_dictionary
            folder_path_to_be_copied=an.values()
            #print folder_path_to_be_copied
            
            for each in folder_path_to_be_copied:
                file_extension=os.path.splitext(each)[-1]
                print file_extension
                                
                if file_extension in ['.MP3', '.WMA', '.WAV', '.MP2', '.AAC', '.AC3', '.AU', '.OGG', '.FLAC']:
                    #each = '/' + each
                    cmd = "pull %s %s"%(each,format_dirs[2])
                    #print cmd
                    B.call_adb(cmd)
                    #a.pull(each,format_dirs[2])
                elif file_extension in ['.jpg','.png','.JPG','.PNG']:
                    #print "jpg reached"
                    #each = '/' + each
                    cmd = "pull %s %s"%(each,format_dirs[1])
                    B.call_adb(cmd)
                    #a.pull(each,format_dirs[1])
                elif file_extension in ['.pdf','.docx','.doc','.xls','.sh','.PDF','.ppt']:
                    #each = '/' + each
                    cmd = "pull %s %s"%(each,format_dirs[0])
                    B.call_adb(cmd)
                    #a.pull(each,format_dirs[0]
                elif file_extension in ['.mkv','.flv','.mp4','.avi']:
                    cmd = "pull %s %s"%(each,format_dirs[3])
                    B.call_adb(cmd)
                else:
                    cmd = "pull %s %s"%(each,format_dirs[4])
                    B.call_adb(cmd)