def accept(self): name = self.name_line_edit.text().strip() password = self.password_line_edit.text() if self.just_save: confirm_password = password else: confirm_password = self.confirm_password_line_edit.text() cred_file = self.cred_file_line_edit.text() project = self.project_line_edit.text().strip() bucket = self.bucket_line_edit.text().strip() prefix = self.prefix_line_edit.text().strip() backup = Backup() backup.name = name backup.location = "Google Cloud" backup.password = password backup.gcp_cred_file = cred_file backup.gcp_project = project backup.gcp_bucket = bucket backup.cloud_prefix = prefix self.backup = backup fs = [Validator.validate_plan_name, Validator.validate_confirm_password, Validator.validate_local_path, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_no_space, Validator.validate_no_space, Validator.validate_backend, Validator.validate_repo] args = [(name, ), (password, confirm_password), (cred_file, ), ("Project", project), ("Bucket", bucket), ("Prefix", prefix), ("Bucket", bucket), ("Prefix", prefix), (backup, ), (backup, self.just_save)] self.setEnabled(False) self.thread = CommandThread(config_worker, {"fs": fs, "args": args}) self.thread.result.connect(self.command_done) self.thread.start()
def accept(self): name = self.name_line_edit.text().strip() password = self.password_line_edit.text() if self.just_save: confirm_password = password else: confirm_password = self.confirm_password_line_edit.text() connection = self.connection_line_edit.text().strip() container = self.container_line_edit.text().strip() prefix = self.prefix_line_edit.text().strip() backup = Backup() backup.name = name backup.location = "Microsoft Azure" backup.password = password backup.azure_conn_str = connection backup.azure_container = container backup.cloud_prefix = prefix self.backup = backup fs = [ Validator.validate_plan_name, Validator.validate_confirm_password, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_no_space, Validator.validate_no_space, Validator.validate_backend, Validator.validate_repo ] args = [(name, ), (password, confirm_password), ("Connection String", connection), ("Container", container), ("Prefix", prefix), ("Container", container), ("Prefix", prefix), (backup, ), (backup, self.just_save)] self.setEnabled(False) self.thread = CommandThread(config_worker, {"fs": fs, "args": args}) self.thread.result.connect(self.command_done) self.thread.start()
def backup_reset(): if request.method == 'POST': b = Backup() b.clear_logfile() b.clear_db() res = b.go_for_it(test_mode=False) return jsonify(res)
def test_get_backend__b2(self): backup = Backup() backup.location = "Backblaze B2" backup.b2_key_id = environ["BLOBBACKUP_B2_KEY_ID"] backup.b2_key = environ["BLOBBACKUP_B2_KEY"] backup.b2_bucket = environ["BLOBBACKUP_B2_BUCKET"] backup.cloud_prefix = "tmp" self._verify_backend(Utils.get_backend(backup), B2Backend)
def test_get_backend__gcp(self): backup = Backup() backup.location = "Google Cloud" backup.gcp_cred_file = environ["BLOBBACKUP_GCP_CRED_FILE"] backup.gcp_project = environ["BLOBBACKUP_GCP_PROJECT"] backup.gcp_bucket = environ["BLOBBACKUP_GCP_BUCKET"] backup.cloud_prefix = "tmp" self._verify_backend(Utils.get_backend(backup), GcpBackend)
def test_get_backend__aws(self): backup = Backup() backup.location = "Amazon AWS" backup.aws_key_id = environ["BLOBBACKUP_AWS_KEY_ID"] backup.aws_key = environ["BLOBBACKUP_AWS_KEY"] backup.aws_bucket = environ["BLOBBACKUP_AWS_BUCKET"] backup.cloud_prefix = "tmp" self._verify_backend(Utils.get_backend(backup), AwsBackend)
def mybackup(request): # 现将今天之前备份过的置为不是最新 today = datetime.date.today() old_backups = Backup.objects.filter(save_datetime__year=today.year, save_datetime__month=today.month, save_datetime__day=today.day) for old_backup in old_backups: old_backup.is_lastet = False old_backup.save() goodss = Goods.objects.order_by('name') for goods in goodss: guoao = GoodsShop.objects.get(goods=goods, shop__name='魅族店') dadian = GoodsShop.objects.get(goods=goods, shop__name='大店') hongwei = GoodsShop.objects.get(goods=goods, shop__name='红卫店') backup = Backup(goods_name=goods.name, goods_type=goods.goods_type, dadian_count=dadian.remain, guoaodian_count=guoao.remain, hongweidian_count=hongwei.remain) backup.save() return HttpResponse('success')
def accept(self): name = self.name_line_edit.text().strip() password = self.password_line_edit.text() if self.just_save: confirm_password = password else: confirm_password = self.confirm_password_line_edit.text() private_key = self.private_key_line_edit.text() username = self.username_line_edit.text().strip() sftp_password = self.sftp_password_line_edit.text().strip() server = self.server_line_edit.text().strip() prefix = self.prefix_line_edit.text().strip() backup = Backup() backup.name = name backup.location = "SFTP" backup.password = password if len(private_key) is not 0: backup.sftp_private_key = private_key backup.sftp_username = username if len(sftp_password) is not 0: backup.sftp_password = sftp_password backup.sftp_server = server backup.cloud_prefix = prefix self.backup = backup fs = [ Validator.validate_plan_name, Validator.validate_confirm_password, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_no_space, Validator.validate_no_space, Validator.validate_no_space, Validator.validate_backend, Validator.validate_repo ] args = [(name, ), (password, confirm_password), ("Username", username), ("Server", server), ("Prefix", prefix), ("Server", server), ("Prefix", prefix), ("Username", username), (backup, ), (backup, self.just_save)] self.setEnabled(False) self.thread = CommandThread(config_worker, {"fs": fs, "args": args}) self.thread.result.connect(self.command_done) self.thread.start()
def test_get_backend__azure(self): backup = Backup() backup.location = "Microsoft Azure" backup.azure_conn_str = environ["BLOBBACKUP_AZURE_CONN_STR"] backup.azure_container = environ["BLOBBACKUP_AZURE_CONTAINER"] backup.cloud_prefix = "tmp" self._verify_backend(Utils.get_backend(backup), AzureBackend)
def accept(self): name = self.name_line_edit.text().strip() password = self.password_line_edit.text() if self.just_save: confirm_password = password else: confirm_password = self.confirm_password_line_edit.text() directory = self.local_directory_line_edit.text() backup = Backup() backup.name = name backup.location = "Local Directory" backup.password = password backup.local_directory = directory self.backup = backup fs = [ Validator.validate_plan_name, Validator.validate_confirm_password, Validator.validate_local_path, Validator.validate_backend, Validator.validate_repo ] args = [(name, ), (password, confirm_password), (directory, ), (backup, ), (backup, self.just_save)] self.setEnabled(False) self.thread = CommandThread(config_worker, {"fs": fs, "args": args}) self.thread.result.connect(self.command_done) self.thread.start()
def accept(self): name = self.name_line_edit.text().strip() password = self.password_line_edit.text() if self.just_save: confirm_password = password else: confirm_password = self.confirm_password_line_edit.text() url = self.s3_url_line_edit.text().strip() key_id = self.key_id_line_edit.text().strip() key = self.key_line_edit.text().strip() bucket = self.bucket_line_edit.text().strip() prefix = self.prefix_line_edit.text().strip() backup = Backup() backup.name = name backup.location = "S3 Storage" backup.password = password backup.s3_url = url backup.aws_key_id = key_id backup.aws_key = key backup.aws_bucket = bucket backup.cloud_prefix = prefix self.backup = backup fs = [ Validator.validate_plan_name, Validator.validate_confirm_password, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_non_empty, Validator.validate_no_space, Validator.validate_no_space, Validator.validate_backend, Validator.validate_repo ] args = [(name, ), (password, confirm_password), ("AWS Key Id", key_id), ("S3 URL", url), ("AWS Key", key), ("Bucket", bucket), ("Prefix", prefix), ("Bucket", bucket), ("Prefix", prefix), (backup, ), (backup, self.just_save)] self.setEnabled(False) self.thread = CommandThread(config_worker, {"fs": fs, "args": args}) self.thread.result.connect(self.command_done) self.thread.start()
def new(request): errorMessage = None activatedKeys = Product.objects.filter(client=request.user,activated=True).values_list('serial','serial') if (request.POST): form = UploadFileForm(request.POST, request.FILES) form.fields['serial_number'] = forms.ChoiceField(choices = activatedKeys ) if form.is_valid(): #import rpdb2 #rpdb2.start_embedded_debugger("1") b = Backup() b.user = request.user b.file=form.cleaned_data['file'] b.mime = request.FILES['file'].content_type b.size = request.FILES['file'].size #b.etva_agent = form.cleaned_data['etva_agent'] b.file_name = (form.cleaned_data['file']).name b.notes=form.cleaned_data['notes'] b.product=Product.objects.get(serial=form.cleaned_data['serial_number'],client=request.user,activated=True) b.save() return HttpResponseRedirect('/backups/') # Redirect after POST else: form = UploadFileForm() form.fields['serial_number'] = forms.ChoiceField(choices = activatedKeys) return render_to_response('backup/new.html', { 'form':form, 'section':SECTION_BACKUPS, 'errorMessage':errorMessage, 'activatedKeys':activatedKeys, },context_instance=RequestContext(request))
def mybackup(request): # 现将今天之前备份过的置为不是最新 today = datetime.date.today() old_backups = Backup.objects.filter(save_datetime__year=today.year, save_datetime__month=today.month, save_datetime__day=today.day) for old_backup in old_backups: old_backup.is_lastet = False old_backup.save() goodss = Goods.objects.order_by('name') for goods in goodss: guoao = GoodsShop.objects.get(goods=goods, shop__name='国奥店') dadian = GoodsShop.objects.get(goods=goods, shop__name='大店') hongwei = GoodsShop.objects.get(goods=goods, shop__name='红卫店') backup = Backup(goods_name=goods.name, goods_type=goods.goods_type, dadian_count=dadian.remain, guoaodian_count=guoao.remain, hongweidian_count=hongwei.remain) backup.save() return HttpResponse('success')
def test_get_backend__local(self): backup = Backup() backup.location = "Local Directory" backup.local_directory = "." self._verify_backend(Utils.get_backend(backup), LocalBackend)
def test_get_backend__memory(self): backup = Backup() backup.location = "Memory" self._verify_backend(Utils.get_backend(backup), MemoryBackend)
def backup(): if request.method == 'POST': b = Backup() res = b.go_for_it(test_mode=False) return jsonify(res) return "ok"