Example #1
0
    def process_filtered_object(self, obj):
        full_path = format_path(obj.full_path)
        print "processing: %s" % full_path

        # if os.path.isdir(full_path):
        #     obj.is_container = True
        # else:
        #     obj.is_container = False
        # obj.save()
        # processed += 1
        # if processed%1000 == 0:
        #     print "processed: %d/%d" % (processed, total_num)
        # continue
        # print u"processing: " + unicode(full_path)
        if not (full_path is None) and (os.path.isdir(full_path)):
            if self.is_ignore_container(obj):
                return
            dir_list = os.listdir(full_path)
            children_process_counter = Counter(len(dir_list), name="Children processing")
            for filename in dir_list:
                if not self.is_ignore(filename):
                    child_full_path = format_path(os.path.join(full_path, filename))
                    # print unicode(child_full_path)
                    new_obj = self.add_obj_from_full_path(child_full_path, obj)
                    if not os.path.isdir(child_full_path):
                        self.set_complete(new_obj)
                    children_process_counter.increase()
    def process_file(self, full_path, obj):
        print "processing: %s" % full_path

        if not (full_path is None) and (os.path.isdir(full_path)) and not self.is_ignore_container(obj):
            self.check_children(obj)
            folder_list = os.listdir(full_path)
            children_process_counter = Counter(len(folder_list), name="Children processing")
            # The following is required. otherwise, the tree will not be displayed correctly.
            with UfsObj.objects.delay_mptt_updates():
                for filename in folder_list:
                    if not self.is_ignore(filename):
                        child_full_path = format_path(os.path.join(full_path, filename))
                        if os.path.isdir(child_full_path):
                            self.create_or_update_obj(child_full_path, obj)
                    children_process_counter.increase()
        self.set_complete(obj)
Example #3
0
 def register_dir_change_notification(self, msg):
     git_folder = msg["path"]
     if not os.path.exists(git_folder):
         return
     pull_and_notify_user(git_folder)
     logging.getLogger(__file__).info("auto pull and push done")
     git_config_folder = os.path.join(git_folder, ".git")
     if os.path.exists(git_config_folder) and not os.path.isdir(git_config_folder):
         git_config_file = open(git_config_folder, 'r')
         real_git_config_folder = git_config_file.readline().split(": ")[1].replace("\r", "").replace("\n", "")
         git_config_folder = os.path.abspath(os.path.join(git_folder, real_git_config_folder))
     git_config_folder = os.path.join(git_config_folder, "refs/heads")
     git_config_folder = format_path(git_config_folder)
     if not (git_config_folder in self.watching_folder_to_git_folder):
         change_notifier = GitFolderChangeNotifier(git_config_folder)
         change_notifier.channel = self.get_channel()
         change_notifier.start()
         self.change_notifiers.append(change_notifier)
         self.watching_folder_to_git_folder[git_config_folder] = git_folder
Example #4
0
 def process_dir_change_msg(self, msg):
     changed_path = format_path(msg["path"])
     if not (changed_path in self.path_updated):
         self.path_updated[changed_path] = datetime.datetime.now()
     # self.is_more_folder_msg_received = True
     thread.start_new_thread(send_delayed_msg, (self.get_channel(), self.DELAY_PULL_SECONDS+5))
Example #5
0
 def get_git_folder_for_changed_folder_root(self, git_config_folder):
     git_folder = format_path(git_config_folder)
     return self.watching_folder_to_git_folder[git_folder]
Example #6
0
def get_ufs_url_for_local_path(full_path):
    return gUfsObjUrlPrefix + get_hostname() + gUfsObjUrlSeparator + format_path(full_path)
Example #7
0
def get_formatted_full_path(full_path):
    return format_path(full_path)
 def process_obj(self, obj):
     full_path = format_path(obj.full_path)
     if not (full_path is None):
         self.process_file(full_path, obj)
     self.counter.increase()