Ejemplo n.º 1
0
def migrate_videos_to_server():
    with MongoDBCollection("website_pron", "video_info",
                           host="192.168.1.103") as remote_coll:
        with MongoDBCollection("website_pron", "video_info") as local_coll:
            with ExtSSHConnection("192.168.1.103", "yuanyifan",
                                  "979323") as ext_ssh:
                for doc in local_coll.find({"source": {"$ne": None}}):
                    if remote_coll.find_one({"source": doc["source"]}) is None:
                        print("Uploading...")
                        print(doc)
                        _id = doc["_id"]
                        current_index = int(
                            remote_coll.find({}, {
                                "_id": 1
                            }).sort("_id", -1).limit(1)[0]["_id"]) + 1
                        insert_doc = doc
                        insert_doc["_id"] = current_index
                        ext_ssh.sftp_conn.put(
                            shortcuts_saving_path % _id,
                            remote_video_preview_path % current_index)
                        ext_ssh.sftp_conn.put(
                            video_saving_path % _id,
                            remote_video_path % current_index)
                        remote_coll.insert_one(insert_doc)
                        print("Uploaded.")
Ejemplo n.º 2
0
def remove_remote_DAGUERRE():
    assert input("Delete all DAGUERRE?(True/False)"), "Paused"
    with MongoDBCollection("website_pron", "images_info", host="192.168.1.103") as remote_coll:
        with ExtSSHConnection("192.168.1.103", "yuanyifan", "979323") as ext_ssh:
            daguerre_ids = [int(doc["_id"]) for doc in remote_coll.find({"block": "DAGUERRE"})]
            for daguerre_id in daguerre_ids:  # 找到所有的达盖尔的旗帜
                print("Removing...%08d" % daguerre_id)
                ext_ssh.run_command('rm -rf "%s"' % (remote_images_path % daguerre_id))
                remote_coll.delete_one({"_id": daguerre_id})
Ejemplo n.º 3
0
def migrate_videos_to_remote():
    with MongoDBCollection("website_pron", "video_info", host="192.168.1.103") as remote_coll:
        with MongoDBCollection("website_pron", "video_info") as local_coll:
            with ExtSSHConnection("192.168.1.103", "yuanyifan", "979323") as ext_ssh:
                for doc in local_coll.find({}):
                    video_id = int(doc["_id"])
                    if remote_coll.find_one({"_id": video_id}) is None:
                        print("Found a log to migrate:\n%s" % json.dumps(doc, indent=2))
                        ext_ssh.sftp_conn.put(video_saving_path % video_id, remote_video_path % video_id)
                        ext_ssh.sftp_conn.put(shortcuts_saving_path % video_id, remote_video_preview_path % video_id)
                        remote_coll.insert_one(doc)
                        print("Migrated a log.")
Ejemplo n.º 4
0
def migrate_images_to_remote():
    with MongoDBCollection("website_pron", "images_info", host="192.168.1.103") as remote_coll:
        with MongoDBCollection("website_pron", "images_info") as local_coll:
            with ExtSSHConnection("192.168.1.103", "yuanyifan", "979323") as ext_ssh:
                for doc in local_coll.find({"block": "DAGUERRE"}):  # 找到所有的达盖尔的旗帜
                    image_page_index = int(doc["_id"])
                    print("Uploading...%08d" % image_page_index)
                    local_path = local_image_list_path % {
                        "page_index": image_page_index
                    }
                    remote_path = remote_images_path % image_page_index
                    ext_ssh.upload_dir(local_path, remote_path)
                    remote_coll.insert_one(doc)
Ejemplo n.º 5
0
 def run(self):
     with ExtSSHConnection(host="173.199.71.121", user="******", passwd="979323846") as ext_ssh:
         self.progress = 10
         command = 'wget "%s" -O "/root/download/%s"' % (self.target_url, self.save_file)
         ext_ssh.run_command(command)
         self.progress = 35
         ext_ssh.sftp_conn.get(
             "/root/download/%s" % self.save_file,
             self.filename,
             callback=lambda x, y: 60.0 * x / y + 35.0)
         self.progress = 95
         ext_ssh.sftp_conn.remove("/root/download/%s" % self.save_file)
         self.progress = 100
def migrate_videos_from_server():
    with MongoDBCollection("website_pron", "video_info",
                           host="192.168.1.103") as remote_coll:
        with MongoDBCollection("website_pron", "video_info") as local_coll:
            with ExtSSHConnection("192.168.1.103", "yuanyifan",
                                  "979323") as ext_ssh:
                for doc in remote_coll.find(
                    {"$or": [{
                        "source": {
                            "$ne": None
                        }
                    }, {
                        "like": True
                    }]}):
                    _id = doc["_id"]
                    if local_coll.find_one({"_id": _id}) is None:
                        print("Downloading...")
                        print(doc)
                        ext_ssh.sftp_conn.get(remote_video_preview_path % _id,
                                              shortcuts_saving_path % _id)
                        ext_ssh.sftp_conn.get(remote_video_path % _id,
                                              video_saving_path % _id)
                        local_coll.insert_one(doc)