backup file from fireftp

_backup_fireftp.py:
import sublime, sublime_plugin
import os, time, shutil, sys
from datetime import datetime
backup_dir = "/home/_username_/tmp/"
class BackupCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.create(sublime.active_window().active_view().file_name())
def create(self, filename):
tNow = datetime.now()
# stamp = '.{:02}{:02}{:02}{:02}{:02}{:02}'.format(tNow.year%100, tNow.month, tNow.day, tNow.hour, tNow.minute , tNow.second)
stamp = '.{:02}{:02}{:02}'.format(tNow.year%100, tNow.month, tNow.day)
filename_ = os.path.basename(filename)[2:] # убираем первые два символа (fireftp добавляет 1-filename.php 2-filename.php ..)
backup_name = backup_dir + os.path.basename(filename_) + stamp;
shutil.copyfile(filename, backup_name)
sublime.status_message("backuped: " + backup_name)

copy to ~/.config/sublime-text-3/Packages/User/




Enter your email address:

Delivered by FeedBurner

Добавить комментарий

Ваш e-mail не будет опубликован. Обязательные поля помечены *