/usr/share/backintime/kde4/settingsdialog.py is in backintime-kde 1.0.34-0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 | # Back In Time
# Copyright (C) 2008-2009 Oprea Dan, Bart de Koning, Richard Bailey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import os
import os.path
import sys
import datetime
import gettext
import copy
import subprocess
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyKDE4.kdecore import *
from PyKDE4.kdeui import *
from PyKDE4.kio import *
import config
import tools
import kde4tools
import mount
import password
_=gettext.gettext
#class PopupAutomaticBackupAction( KAction ):
# def __init__( self, list, id, label ):
# KAction.__init__( self, label, list )
# self.list = list
# self.id = id
# self.label = label
#
# QObject.connect( self, SIGNAL('triggered()'), self.on_selected )
#
# def on_selected( self ):
# item = self.list.currentItem()
# if not item is None:
# item.setText( 1, QString.fromUtf8( self.label ) )
# item.setData( 0, Qt.UserRole, QVariant( self.id ) )
class SettingsDialog( KDialog ):
def __init__( self, parent ):
KDialog.__init__( self, parent )
self.config = parent.config
self.snapshots = parent.snapshots
self.config_copy_dict = copy.copy( self.config.dict )
self.current_profile_org = self.config.get_current_profile()
self.setWindowIcon( KIcon( 'configure' ) )
self.setCaption( QString.fromUtf8( _( 'Settings' ) ) )
self.main_widget = QWidget( self )
self.main_layout = QVBoxLayout( self.main_widget )
self.setMainWidget( self.main_widget )
#profiles
layout = QHBoxLayout()
self.main_layout.addLayout( layout )
layout.addWidget( QLabel( QString.fromUtf8( _('Profile:') ), self ) )
self.first_update_all = True
self.disable_profile_changed = True
self.combo_profiles = KComboBox( self )
layout.addWidget( self.combo_profiles, 1 )
QObject.connect( self.combo_profiles, SIGNAL('currentIndexChanged(int)'), self.current_profile_changed )
self.disable_profile_changed = False
self.btn_edit_profile = KPushButton( KIcon( 'edit-rename' ), QString.fromUtf8( _('Edit') ), self )
QObject.connect( self.btn_edit_profile, SIGNAL('clicked()'), self.edit_profile )
layout.addWidget( self.btn_edit_profile )
self.btn_add_profile = KPushButton( KStandardGuiItem.add(), self )
QObject.connect( self.btn_add_profile, SIGNAL('clicked()'), self.add_profile )
layout.addWidget( self.btn_add_profile )
self.btn_remove_profile = KPushButton( KStandardGuiItem.remove(), self )
QObject.connect( self.btn_remove_profile, SIGNAL('clicked()'), self.remove_profile )
layout.addWidget( self.btn_remove_profile )
#TABs
self.tabs_widget = KTabWidget( self )
self.main_layout.addWidget( self.tabs_widget )
#TAB: General
tab_widget = QWidget( self )
self.tabs_widget.addTab( tab_widget, QString.fromUtf8( _( 'General' ) ) )
layout = QVBoxLayout( tab_widget )
#select mode
self.mode = None
vlayout = QVBoxLayout()
layout.addLayout( vlayout )
self.lbl_modes = QLabel( QString.fromUtf8( _( 'Mode:' ) ), self )
vlayout.addWidget( self.lbl_modes )
self.combo_modes = KComboBox( self )
vlayout.addWidget( self.combo_modes )
store_modes = {}
for key in self.config.SNAPSHOT_MODES.keys():
store_modes[key] = self.config.SNAPSHOT_MODES[key][1]
self.fill_combo( self.combo_modes, store_modes )
#Where to save snapshots
group_box = QGroupBox( self )
self.mode_local = group_box
group_box.setTitle( QString.fromUtf8( _( 'Where to save snapshots' ) ) )
layout.addWidget( group_box )
vlayout = QVBoxLayout( group_box )
hlayout = QHBoxLayout()
vlayout.addLayout( hlayout )
self.edit_snapshots_path = KLineEdit( self )
self.edit_snapshots_path.setReadOnly( True )
hlayout.addWidget( self.edit_snapshots_path )
self.btn_snapshots_path = KPushButton( KIcon( 'folder' ), '', self )
hlayout.addWidget( self.btn_snapshots_path )
QObject.connect( self.btn_snapshots_path, SIGNAL('clicked()'), self.on_btn_snapshots_path_clicked )
#SSH
group_box = QGroupBox( self )
self.mode_ssh = group_box
group_box.setTitle( QString.fromUtf8( _( 'SSH Settings' ) ) )
layout.addWidget( group_box )
vlayout = QVBoxLayout( group_box )
hlayout1 = QHBoxLayout()
vlayout.addLayout( hlayout1 )
hlayout2 = QHBoxLayout()
vlayout.addLayout( hlayout2 )
hlayout3 = QHBoxLayout()
vlayout.addLayout( hlayout3 )
self.lbl_ssh_host = QLabel( QString.fromUtf8( _( 'Host:' ) ), self )
hlayout1.addWidget( self.lbl_ssh_host )
self.txt_ssh_host = KLineEdit( self )
hlayout1.addWidget( self.txt_ssh_host )
self.lbl_ssh_port = QLabel( QString.fromUtf8( _( 'Port:' ) ), self )
hlayout1.addWidget( self.lbl_ssh_port )
self.txt_ssh_port = KLineEdit( self )
hlayout1.addWidget( self.txt_ssh_port )
self.lbl_ssh_user = QLabel( QString.fromUtf8( _( 'User:' ) ), self )
hlayout1.addWidget( self.lbl_ssh_user )
self.txt_ssh_user = KLineEdit( self )
hlayout1.addWidget( self.txt_ssh_user )
self.lbl_ssh_path = QLabel( QString.fromUtf8( _( 'Path:' ) ), self )
hlayout2.addWidget( self.lbl_ssh_path )
self.txt_ssh_path = KLineEdit( self )
hlayout2.addWidget( self.txt_ssh_path )
self.lbl_ssh_cipher = QLabel( QString.fromUtf8( _( 'Cipher:' ) ), self )
hlayout3.addWidget( self.lbl_ssh_cipher )
self.combo_ssh_cipher = KComboBox( self )
hlayout3.addWidget( self.combo_ssh_cipher )
self.fill_combo( self.combo_ssh_cipher, self.config.SSH_CIPHERS )
self.lbl_ssh_private_key_file = QLabel( QString.fromUtf8( _( 'Private Key:' ) ), self )
hlayout3.addWidget( self.lbl_ssh_private_key_file )
self.txt_ssh_private_key_file = KLineEdit( self )
self.txt_ssh_private_key_file.setReadOnly( True )
hlayout3.addWidget( self.txt_ssh_private_key_file )
self.btn_ssh_private_key_file = KPushButton( KIcon( 'folder' ), '', self )
hlayout3.addWidget( self.btn_ssh_private_key_file )
QObject.connect( self.btn_ssh_private_key_file, SIGNAL('clicked()'), self.on_btn_ssh_private_key_file_clicked )
kde4tools.equal_indent(self.lbl_ssh_host, self.lbl_ssh_path, self.lbl_ssh_cipher)
#encfs
self.mode_local_encfs = self.mode_local
self.mode_ssh_encfs = self.mode_ssh
## #Dummy
## group_box = QGroupBox( self )
## self.mode_dummy = group_box
## group_box.setTitle( QString.fromUtf8( _( 'Dummy Settings' ) ) )
## layout.addWidget( group_box )
##
## vlayout = QVBoxLayout( group_box )
##
## hlayout = QHBoxLayout()
## vlayout.addLayout( hlayout )
##
## self.lbl_dummy_host = QLabel( QString.fromUtf8( _( 'Host:' ) ), self )
## hlayout.addWidget( self.lbl_dummy_host )
## self.txt_dummy_host = KLineEdit( self )
## hlayout.addWidget( self.txt_dummy_host )
##
## self.lbl_dummy_port = QLabel( QString.fromUtf8( _( 'Port:' ) ), self )
## hlayout.addWidget( self.lbl_dummy_port )
## self.txt_dummy_port = KLineEdit( self )
## hlayout.addWidget( self.txt_dummy_port )
##
## self.lbl_dummy_user = QLabel( QString.fromUtf8( _( 'User:' ) ), self )
## hlayout.addWidget( self.lbl_dummy_user )
## self.txt_dummy_user = KLineEdit( self )
## hlayout.addWidget( self.txt_dummy_user )
#password
group_box = QGroupBox( self )
self.frame_password_1 = group_box
group_box.setTitle( QString.fromUtf8( _( 'Password' ) ) )
layout.addWidget( group_box )
vlayout = QVBoxLayout( group_box )
hlayout1 = QHBoxLayout()
vlayout.addLayout(hlayout1)
hlayout2 = QHBoxLayout()
vlayout.addLayout(hlayout2)
self.lbl_password_1 = QLabel( QString.fromUtf8( _( 'Password' ) ), self )
hlayout1.addWidget( self.lbl_password_1 )
self.txt_password_1 = KLineEdit( self )
self.txt_password_1.setPasswordMode(True)
hlayout1.addWidget( self.txt_password_1 )
self.lbl_password_2 = QLabel( QString.fromUtf8( _( 'Password' ) ), self )
hlayout2.addWidget( self.lbl_password_2 )
self.txt_password_2 = KLineEdit( self )
self.txt_password_2.setPasswordMode(True)
hlayout2.addWidget( self.txt_password_2 )
self.cb_password_save = QCheckBox( QString.fromUtf8( _( 'Save Password to Keyring' ) ), self )
vlayout.addWidget( self.cb_password_save )
self.cb_password_use_cache = QCheckBox( QString.fromUtf8( _( 'Cache Password for Cron (Security issue: root can read password)' ) ), self )
vlayout.addWidget( self.cb_password_use_cache )
self.keyring_supported = tools.keyring_supported()
self.cb_password_save.setEnabled(self.keyring_supported)
#mode change
QObject.connect( self.combo_modes, SIGNAL('currentIndexChanged(int)'), self.on_combo_modes_changed )
#host, user, profile id
group_box = QGroupBox( self )
self.frame_advanced = group_box
group_box.setTitle( QString.fromUtf8( _( 'Advanced' ) ) )
layout.addWidget( group_box )
hlayout = QHBoxLayout( group_box )
hlayout.addSpacing( 12 )
vlayout2 = QVBoxLayout()
hlayout.addLayout( vlayout2 )
hlayout2 = QHBoxLayout()
vlayout2.addLayout( hlayout2 )
self.cb_auto_host_user_profile = QCheckBox( QString.fromUtf8( _( 'Auto Host / User / Profile Id' ) ), self )
QObject.connect( self.cb_auto_host_user_profile, SIGNAL('stateChanged(int)'), self.update_host_user_profile )
hlayout2.addWidget( self.cb_auto_host_user_profile )
hlayout2 = QHBoxLayout()
vlayout2.addLayout( hlayout2 )
self.lbl_host = QLabel( QString.fromUtf8( _( 'Host:' ) ), self )
hlayout2.addWidget( self.lbl_host )
self.txt_host = KLineEdit( self )
hlayout2.addWidget( self.txt_host )
self.lbl_user = QLabel( QString.fromUtf8( _( 'User:' ) ), self )
hlayout2.addWidget( self.lbl_user )
self.txt_user = KLineEdit( self )
hlayout2.addWidget( self.txt_user )
self.lbl_profile = QLabel( QString.fromUtf8( _( 'Profile:' ) ), self )
hlayout2.addWidget( self.lbl_profile )
self.txt_profile = KLineEdit( self )
hlayout2.addWidget( self.txt_profile )
#Schedule
group_box = QGroupBox( self )
self.global_schedule_group_box = group_box
group_box.setTitle( QString.fromUtf8( _( 'Schedule' ) ) )
layout.addWidget( group_box )
glayout = QGridLayout( group_box )
glayout.setColumnStretch(1, 2)
self.combo_automatic_snapshots = KComboBox( self )
glayout.addWidget( self.combo_automatic_snapshots, 0, 0, 1, 2 )
self.fill_combo( self.combo_automatic_snapshots, self.config.AUTOMATIC_BACKUP_MODES )
self.lbl_automatic_snapshots_day = QLabel( QString.fromUtf8( _( 'Day:' ) ), self )
self.lbl_automatic_snapshots_day.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_day.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget( self.lbl_automatic_snapshots_day, 1, 0 )
self.combo_automatic_snapshots_day = KComboBox( self )
glayout.addWidget( self.combo_automatic_snapshots_day, 1, 1 )
for d in xrange( 1, 29 ):
self.combo_automatic_snapshots_day.addItem( QIcon(), QString.fromUtf8( str(d) ), QVariant( d ) )
self.lbl_automatic_snapshots_weekday = QLabel( QString.fromUtf8( _( 'Weekday:' ) ), self )
self.lbl_automatic_snapshots_weekday.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_weekday.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget( self.lbl_automatic_snapshots_weekday, 2, 0 )
self.combo_automatic_snapshots_weekday = KComboBox( self )
glayout.addWidget( self.combo_automatic_snapshots_weekday, 2, 1 )
for d in xrange( 1, 8 ):
self.combo_automatic_snapshots_weekday.addItem( QIcon(), QString.fromUtf8( datetime.date(2011, 11, 6 + d).strftime("%A") ), QVariant( d ) )
self.lbl_automatic_snapshots_time = QLabel( QString.fromUtf8( _( 'Hour:' ) ), self )
self.lbl_automatic_snapshots_time.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_time.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget( self.lbl_automatic_snapshots_time, 3, 0 )
self.combo_automatic_snapshots_time = KComboBox( self )
glayout.addWidget( self.combo_automatic_snapshots_time, 3, 1 )
for t in xrange( 0, 2300, 100 ):
self.combo_automatic_snapshots_time.addItem( QIcon(), QString.fromUtf8( datetime.time( t/100, t%100 ).strftime("%H:%M") ), QVariant( t ) )
self.lbl_automatic_snapshots_time_custom = QLabel( QString.fromUtf8( _( 'Hours:' ) ), self )
self.lbl_automatic_snapshots_time_custom.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_time_custom.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget( self.lbl_automatic_snapshots_time_custom, 4, 0 )
self.txt_automatic_snapshots_time_custom = KLineEdit( self )
glayout.addWidget( self.txt_automatic_snapshots_time_custom, 4, 1 )
#anacron
self.lbl_automatic_snapshots_anacron = QLabel(QString.fromUtf8(_('Run Back In Time periodically with anacron. This is useful if the computer is not running regular.')))
self.lbl_automatic_snapshots_anacron.setWordWrap(True)
glayout.addWidget(self.lbl_automatic_snapshots_anacron, 5, 0, 1, 2)
self.lbl_automatic_snapshots_anacron_period = QLabel(QString.fromUtf8(_('Frequency in days:')))
self.lbl_automatic_snapshots_anacron_period.setContentsMargins( 5, 0, 0, 0 )
self.lbl_automatic_snapshots_anacron_period.setAlignment( Qt.AlignRight | Qt.AlignVCenter )
glayout.addWidget(self.lbl_automatic_snapshots_anacron_period, 7, 0)
self.sb_automatic_snapshots_anacron_period = QSpinBox(self)
self.sb_automatic_snapshots_anacron_period.setSingleStep( 1 )
self.sb_automatic_snapshots_anacron_period.setRange( 1, 10000 )
glayout.addWidget(self.sb_automatic_snapshots_anacron_period, 7, 1)
#udev
self.lbl_automatic_snapshots_udev = QLabel(QString.fromUtf8(_('Run Back In Time as soon as the drive is connected (only once every X days).\nYou will be prompted for your sudo password.')))
self.lbl_automatic_snapshots_udev.setWordWrap(True)
glayout.addWidget(self.lbl_automatic_snapshots_udev, 6, 0, 1, 2)
QObject.connect( self.combo_automatic_snapshots, SIGNAL('currentIndexChanged(int)'), self.current_automatic_snapshot_changed )
#
layout.addStretch()
#TAB: Include
tab_widget = QWidget( self )
self.tabs_widget.addTab( tab_widget, QString.fromUtf8( _( 'Include' ) ) )
layout = QVBoxLayout( tab_widget )
self.list_include = QTreeWidget( self )
self.list_include.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.list_include.setRootIsDecorated( False )
#self.list_include.setEditTriggers( QAbstractItemView.NoEditTriggers )
#self.list_include.setHeaderLabels( [ QString.fromUtf8( _('Include folders') ), QString.fromUtf8( _('Automatic backup') ) ] )
self.list_include.setHeaderLabels( [ QString.fromUtf8( _('Include files and folders') ) ] )
self.list_include.header().setResizeMode( 0, QHeaderView.Stretch )
#self.popup_automatic_backup = KMenu( self )
#keys = self.config.AUTOMATIC_BACKUP_MODES.keys()
#keys.sort()
#for key in keys:
# self.popup_automatic_backup.addAction( PopupAutomaticBackupAction( self.list_include, key, QString.fromUtf8( self.config.AUTOMATIC_BACKUP_MODES[ key ] ) ) )
#QObject.connect( self.list_include, SIGNAL('itemActivated(QTreeWidgetItem*,int)'), self.on_list_include_item_activated )
layout.addWidget( self.list_include )
buttons_layout = QHBoxLayout()
layout.addLayout( buttons_layout )
self.btn_include_file_add = KPushButton( KStandardGuiItem.add(), self )
self.btn_include_file_add.setText( QString.fromUtf8( _( 'Add file' ) ) )
buttons_layout.addWidget( self.btn_include_file_add )
QObject.connect( self.btn_include_file_add, SIGNAL('clicked()'), self.on_btn_include_file_add_clicked )
self.btn_include_add = KPushButton( KStandardGuiItem.add(), self )
self.btn_include_add.setText( QString.fromUtf8( _( 'Add folder' ) ) )
buttons_layout.addWidget( self.btn_include_add )
QObject.connect( self.btn_include_add, SIGNAL('clicked()'), self.on_btn_include_add_clicked )
self.btn_include_remove = KPushButton( KStandardGuiItem.remove(), self )
buttons_layout.addWidget( self.btn_include_remove )
QObject.connect( self.btn_include_remove, SIGNAL('clicked()'), self.on_btn_include_remove_clicked )
#TAB: Exclude
tab_widget = QWidget( self )
self.tabs_widget.addTab( tab_widget, QString.fromUtf8( _( 'Exclude' ) ) )
layout = QVBoxLayout( tab_widget )
label = QLabel( QString.fromUtf8( _('<b>Warning:</b> Wildcards (\'foo*\', \'[fF]oo\', \'fo?\') will be ignored with mode \'SSH encrypted\'.\nOnly separate asterisk are allowed (\'foo/*\', \'foo/**/bar\')') ), self )
label.setWordWrap(True)
self.lbl_ssh_encfs_exclude_warning = label
layout.addWidget( label )
self.list_exclude = KListWidget( self )
self.list_exclude.setSelectionMode(QAbstractItemView.ExtendedSelection)
layout.addWidget( self.list_exclude )
label = QLabel( QString.fromUtf8( _('Highly recommended:') ), self )
kde4tools.set_font_bold( label )
layout.addWidget( label )
label = QLabel( QString.fromUtf8( ', '.join(self.config.DEFAULT_EXCLUDE) ), self )
label.setWordWrap(True)
layout.addWidget( label )
buttons_layout = QHBoxLayout()
layout.addLayout( buttons_layout )
self.btn_exclude_add = KPushButton( KStandardGuiItem.add(), self )
buttons_layout.addWidget( self.btn_exclude_add )
QObject.connect( self.btn_exclude_add, SIGNAL('clicked()'), self.on_btn_exclude_add_clicked )
self.btn_exclude_file = KPushButton( KStandardGuiItem.add(), self )
self.btn_exclude_file.setText( QString.fromUtf8( _( 'Add file' ) ) )
buttons_layout.addWidget( self.btn_exclude_file )
QObject.connect( self.btn_exclude_file, SIGNAL('clicked()'), self.on_btn_exclude_file_clicked )
self.btn_exclude_folder = KPushButton( KStandardGuiItem.add(), self )
self.btn_exclude_folder.setText( QString.fromUtf8( _( 'Add folder' ) ) )
buttons_layout.addWidget( self.btn_exclude_folder )
QObject.connect( self.btn_exclude_folder, SIGNAL('clicked()'), self.on_btn_exclude_folder_clicked )
self.btn_exclude_remove = KPushButton( KStandardGuiItem.remove(), self )
buttons_layout.addWidget( self.btn_exclude_remove )
QObject.connect( self.btn_exclude_remove, SIGNAL('clicked()'), self.on_btn_exclude_remove_clicked )
#TAB: Auto-remove
tab_widget = QWidget( self )
self.tabs_widget.addTab( tab_widget, QString.fromUtf8( _( 'Auto-remove' ) ) )
layout = QGridLayout( tab_widget )
#remove old snapshots
self.cb_remove_older_then = QCheckBox( QString.fromUtf8( _( 'Older than:' ) ), self )
layout.addWidget( self.cb_remove_older_then, 0, 0 )
QObject.connect( self.cb_remove_older_then, SIGNAL('stateChanged(int)'), self.update_remove_older_than )
self.edit_remove_older_then = KIntSpinBox( 1, 1000, 1, 1, self )
layout.addWidget( self.edit_remove_older_then, 0, 1 )
self.combo_remove_older_then = KComboBox( self )
layout.addWidget( self.combo_remove_older_then, 0, 2 )
self.fill_combo( self.combo_remove_older_then, self.config.REMOVE_OLD_BACKUP_UNITS )
#min free space
enabled, value, unit = self.config.get_min_free_space()
self.cb_min_free_space = QCheckBox( QString.fromUtf8( _( 'If free space is less than:' ) ), self )
layout.addWidget( self.cb_min_free_space, 1, 0 )
QObject.connect( self.cb_min_free_space, SIGNAL('stateChanged(int)'), self.update_min_free_space )
self.edit_min_free_space = KIntSpinBox( 1, 1000, 1, 1, self )
layout.addWidget( self.edit_min_free_space, 1, 1 )
self.combo_min_free_space = KComboBox( self )
layout.addWidget( self.combo_min_free_space, 1, 2 )
self.fill_combo( self.combo_min_free_space, self.config.MIN_FREE_SPACE_UNITS )
#min free inodes
self.cb_min_free_inodes = QCheckBox(QString.fromUtf8( _('If free inodes is less than:') ), self)
layout.addWidget(self.cb_min_free_inodes, 2, 0)
QObject.connect( self.cb_min_free_inodes, SIGNAL('stateChanged(int)'), self.update_min_free_inodes)
self.edit_min_free_inodes = QSpinBox(self)
self.edit_min_free_inodes.setSuffix( QString.fromUtf8(' %') )
self.edit_min_free_inodes.setSingleStep( 1 )
self.edit_min_free_inodes.setRange( 0, 15 )
layout.addWidget(self.edit_min_free_inodes, 2, 1)
#smart remove
self.cb_smart_remove = QCheckBox( QString.fromUtf8( _( 'Smart remove' ) ), self )
layout.addWidget( self.cb_smart_remove, 3, 0 )
#label = QLabel( QString.fromUtf8( _( '- keep all snapshots from today and yesterday\n- keep one snapshot for the last week and one for two weeks ago\n- keep one snapshot per month for all previous months of this year and all months of the last year \n- keep one snapshot per year for all other years' ) ),self )
#label.setContentsMargins( 25, 0, 0, 0 )
#layout.addWidget( label, 3, 0, 1, 3 )
widget = QWidget( self )
widget.setContentsMargins( 25, 0, 0, 0 )
layout.addWidget( widget, 4, 0, 1, 3 )
smlayout = QGridLayout( widget )
smlayout.addWidget( QLabel( QString.fromUtf8( _( 'Keep all snapshots for the last' ) ), self ), 0, 0 )
self.edit_keep_all = KIntSpinBox( 1, 10000, 1, 1, self )
smlayout.addWidget( self.edit_keep_all, 0, 1 )
smlayout.addWidget( QLabel( QString.fromUtf8( _( 'day(s)' ) ), self ), 0, 2 )
smlayout.addWidget( QLabel( QString.fromUtf8( _( 'Keep one snapshot per day for the last' ) ), self ), 1, 0 )
self.edit_keep_one_per_day = KIntSpinBox( 1, 10000, 1, 1, self )
smlayout.addWidget( self.edit_keep_one_per_day, 1, 1 )
smlayout.addWidget( QLabel( QString.fromUtf8( _( 'day(s)' ) ), self ), 1, 2 )
smlayout.addWidget( QLabel( QString.fromUtf8( _( 'Keep one snapshot per week for the last' ) ), self ), 2, 0 )
self.edit_keep_one_per_week = KIntSpinBox( 1, 10000, 1, 1, self )
smlayout.addWidget( self.edit_keep_one_per_week, 2, 1 )
smlayout.addWidget( QLabel( QString.fromUtf8( _( 'weeks(s)' ) ), self ), 2, 2 )
smlayout.addWidget( QLabel( QString.fromUtf8( _( 'Keep one snapshot per month for the last' ) ), self ), 3, 0 )
self.edit_keep_one_per_month = KIntSpinBox( 1, 10000, 1, 1, self )
smlayout.addWidget( self.edit_keep_one_per_month, 3, 1 )
smlayout.addWidget( QLabel( QString.fromUtf8( _( 'month(s)' ) ), self ), 3, 2 )
smlayout.addWidget( QLabel( QString.fromUtf8( _( 'Keep one snapshot per year for all years' ) ), self ), 4, 0, 1, 3 )
#don't remove named snapshots
self.cb_dont_remove_named_snapshots = QCheckBox( QString.fromUtf8( _( 'Don\'t remove named snapshots' ) ), self )
layout.addWidget( self.cb_dont_remove_named_snapshots, 5, 0, 1, 3 )
#
layout.addWidget( QWidget(), 6, 0 )
layout.setRowStretch( 6, 2 )
#TAB: Options
tab_widget = QWidget( self )
self.tabs_widget.addTab( tab_widget, QString.fromUtf8( _( 'Options' ) ) )
layout = QVBoxLayout( tab_widget )
self.cb_notify_enabled = QCheckBox( QString.fromUtf8( _( 'Enable notifications' ) ), self )
layout.addWidget( self.cb_notify_enabled )
self.cb_no_on_battery = QCheckBox( QString.fromUtf8( _( 'Disable snapshots when on battery' ) ), self )
if not tools.power_status_available ():
self.cb_no_on_battery.setEnabled ( False )
self.cb_no_on_battery.setToolTip ( QString.fromUtf8 ( _( 'Power status not available from system' ) ) )
layout.addWidget( self.cb_no_on_battery )
self.cb_backup_on_restore = QCheckBox( QString.fromUtf8( _( 'Backup files on restore' ) ), self )
layout.addWidget( self.cb_backup_on_restore )
self.cb_continue_on_errors = QCheckBox( QString.fromUtf8( _( 'Continue on errors (keep incomplete snapshots)' ) ), self )
layout.addWidget( self.cb_continue_on_errors )
self.cb_use_checksum = QCheckBox( QString.fromUtf8( _( 'Use checksum to detect changes' ) ), self )
layout.addWidget( self.cb_use_checksum )
self.cb_full_rsync = QCheckBox( QString.fromUtf8( _( 'Full rsync mode. May be faster but:' ) ), self )
label = QLabel( QString.fromUtf8( _('- snapshots are no read-only\n- destination file-system must support all linux attributes (dates, rights, user, group ...)') ), self)
label.setIndent(36)
label.setWordWrap(True)
QObject.connect( self.cb_full_rsync, SIGNAL('stateChanged(int)'), self.update_check_for_changes )
layout.addWidget( self.cb_full_rsync )
layout.addWidget( label )
self.cb_check_for_changes = QCheckBox( QString.fromUtf8( _( 'Check for changes (don\'t take a new snapshot if nothing changed)' ) ), self )
layout.addWidget( self.cb_check_for_changes )
#log level
hlayout = QHBoxLayout()
layout.addLayout( hlayout )
hlayout.addWidget( QLabel( QString.fromUtf8( _('Log Level:') ), self ) )
self.combo_log_level = KComboBox( self )
hlayout.addWidget( self.combo_log_level, 1 )
self.combo_log_level.addItem( QIcon(), QString.fromUtf8( _('None') ), QVariant(0) )
self.combo_log_level.addItem( QIcon(), QString.fromUtf8( _('Errors') ), QVariant(1) )
self.combo_log_level.addItem( QIcon(), QString.fromUtf8( _('Changes & Errors') ), QVariant(2) )
self.combo_log_level.addItem( QIcon(), QString.fromUtf8( _('All') ), QVariant(3) )
#
layout.addStretch()
#TAB: Expert Options
tab_widget = QWidget( self )
self.tabs_widget.addTab( tab_widget, QString.fromUtf8( _( 'Expert Options' ) ) )
layout = QVBoxLayout( tab_widget )
label = QLabel( QString.fromUtf8( _('Change these options only if you really know what you are doing !') ), self )
kde4tools.set_font_bold( label )
layout.addWidget( label )
#self.cb_per_diretory_schedule = QCheckBox( QString.fromUtf8( _( 'Enable schedule per included folder (see Include tab; default: disabled)' ) ), self )
#layout.addWidget( self.cb_per_diretory_schedule )
#QObject.connect( self.cb_per_diretory_schedule, SIGNAL('clicked()'), self.update_include_columns )
self.cb_run_nice_from_cron = QCheckBox( QString.fromUtf8( _( 'Run \'nice\' as cron job (default: enabled)' ) ), self )
layout.addWidget( self.cb_run_nice_from_cron )
self.cb_run_ionice_from_cron = QCheckBox( QString.fromUtf8( _( 'Run \'ionice\' as cron job (default: enabled)' ) ), self )
layout.addWidget( self.cb_run_ionice_from_cron )
self.cb_run_ionice_from_user = QCheckBox( QString.fromUtf8( _( 'Run \'ionice\' when taking a manual snapshot (default: disabled)' ) ), self )
layout.addWidget( self.cb_run_ionice_from_user )
self.cb_run_nice_on_remote = QCheckBox(QString.fromUtf8( _('Run \'nice\' on remote host (default: disabled)') ), self)
layout.addWidget(self.cb_run_nice_on_remote)
self.cb_run_ionice_on_remote = QCheckBox(QString.fromUtf8( _('Run \'ionice\' on remote host (default: disabled)') ), self)
layout.addWidget(self.cb_run_ionice_on_remote)
#bwlimit
hlayout = QHBoxLayout()
layout.addLayout(hlayout)
self.cb_bwlimit = QCheckBox( QString.fromUtf8( _( 'Limit rsync bandwidth usage: ' ) ), self )
hlayout.addWidget( self.cb_bwlimit )
self.sb_bwlimit = QSpinBox(self)
self.sb_bwlimit.setSuffix( QString.fromUtf8( _(' KB/sec') ) )
self.sb_bwlimit.setSingleStep( 100 )
self.sb_bwlimit.setRange( 0, 1000000 )
hlayout.addWidget(self.sb_bwlimit)
self.cb_preserve_acl = QCheckBox( QString.fromUtf8( _( 'Preserve ACL' ) ), self )
layout.addWidget( self.cb_preserve_acl )
self.cb_preserve_xattr = QCheckBox( QString.fromUtf8( _( 'Preserve extended attributes (xattr)' ) ), self )
layout.addWidget( self.cb_preserve_xattr )
self.cb_copy_unsafe_links = QCheckBox( QString.fromUtf8( _( 'Copy unsafe links (works only with absolute links)' ) ), self )
layout.addWidget( self.cb_copy_unsafe_links )
self.cb_copy_links = QCheckBox( QString.fromUtf8( _( 'Copy links (dereference symbolic links)' ) ), self )
layout.addWidget( self.cb_copy_links )
#
layout.addStretch()
self.update_profiles()
self.on_combo_modes_changed()
def add_profile( self ):
ret_val = KInputDialog.getText( QString.fromUtf8( _( 'New profile' ) ), '', '', self )
if not ret_val[1]:
return
name = str( ret_val[0].toUtf8() ).strip()
if len( name ) <= 0:
return
profile_id = self.config.add_profile( name )
if profile_id is None:
return
self.config.set_current_profile( profile_id )
self.update_profiles()
def edit_profile( self ):
ret_val = KInputDialog.getText( QString.fromUtf8( _( 'Rename profile' ) ), '', '', self )
if not ret_val[1]:
return
name = str( ret_val[0].toUtf8() ).strip()
if len( name ) <= 0:
return
if not self.config.set_profile_name( name ):
return
self.update_profiles()
def remove_profile( self ):
if self.question_handler( _('Are you sure you want to delete the profile "%s" ?') % self.config.get_profile_name() ):
self.config.remove_profile()
self.update_profiles()
def update_automatic_snapshot_time( self, backup_mode ):
if backup_mode == self.config.CUSTOM_HOUR:
self.lbl_automatic_snapshots_time_custom.show()
self.txt_automatic_snapshots_time_custom.show()
else:
self.lbl_automatic_snapshots_time_custom.hide()
self.txt_automatic_snapshots_time_custom.hide()
if backup_mode == self.config.WEEK:
self.lbl_automatic_snapshots_weekday.show()
self.combo_automatic_snapshots_weekday.show()
else:
self.lbl_automatic_snapshots_weekday.hide()
self.combo_automatic_snapshots_weekday.hide()
if backup_mode == self.config.MONTH:
self.lbl_automatic_snapshots_day.show()
self.combo_automatic_snapshots_day.show()
else:
self.lbl_automatic_snapshots_day.hide()
self.combo_automatic_snapshots_day.hide()
if backup_mode >= self.config.DAY:
self.lbl_automatic_snapshots_time.show()
self.combo_automatic_snapshots_time.show()
else:
self.lbl_automatic_snapshots_time.hide()
self.combo_automatic_snapshots_time.hide()
if self.config.DAY_ANACRON <= backup_mode <= self.config.UDEV:
self.lbl_automatic_snapshots_anacron_period.show()
self.sb_automatic_snapshots_anacron_period.show()
self.lbl_automatic_snapshots_time.hide()
self.combo_automatic_snapshots_time.hide()
else:
self.lbl_automatic_snapshots_anacron_period.hide()
self.sb_automatic_snapshots_anacron_period.hide()
if backup_mode == self.config.DAY_ANACRON:
self.lbl_automatic_snapshots_anacron.show()
else:
self.lbl_automatic_snapshots_anacron.hide()
if backup_mode == self.config.UDEV:
self.lbl_automatic_snapshots_udev.show()
else:
self.lbl_automatic_snapshots_udev.hide()
def current_automatic_snapshot_changed( self, index ):
backup_mode = self.combo_automatic_snapshots.itemData( index ).toInt()[0]
self.update_automatic_snapshot_time( backup_mode )
def current_profile_changed( self, index ):
if self.disable_profile_changed:
return
profile_id = str( self.combo_profiles.itemData( index ).toString().toUtf8() )
if len( profile_id ) <= 0:
return
if profile_id != self.config.get_current_profile():
self.save_profile()
self.config.set_current_profile( profile_id )
self.update_profile()
def update_host_user_profile( self ):
enabled = not self.cb_auto_host_user_profile.isChecked()
self.lbl_host.setEnabled( enabled )
self.txt_host.setEnabled( enabled )
self.lbl_user.setEnabled( enabled )
self.txt_user.setEnabled( enabled )
self.lbl_profile.setEnabled( enabled )
self.txt_profile.setEnabled( enabled )
def update_check_for_changes(self):
enabled = not self.cb_full_rsync.isChecked()
self.cb_check_for_changes.setEnabled( enabled )
def update_profiles( self ):
self.update_profile()
current_profile_id = self.config.get_current_profile()
self.disable_profile_changed = True
self.combo_profiles.clear()
profiles = self.config.get_profiles_sorted_by_name()
for profile_id in profiles:
self.combo_profiles.addItem( QString.fromUtf8( self.config.get_profile_name( profile_id ) ), QVariant( QString.fromUtf8( profile_id ) ) )
if profile_id == current_profile_id:
self.combo_profiles.setCurrentIndex( self.combo_profiles.count() - 1 )
self.disable_profile_changed = False
def update_profile( self ):
if self.config.get_current_profile() == '1':
self.btn_edit_profile.setEnabled( False )
self.btn_remove_profile.setEnabled( False )
else:
self.btn_edit_profile.setEnabled( True )
self.btn_remove_profile.setEnabled( True )
#TAB: General
#mode
self.set_combo_value( self.combo_modes, self.config.get_snapshots_mode(), type = 'str' )
#local
self.edit_snapshots_path.setText( QString.fromUtf8( self.config.get_snapshots_path( mode = 'local') ) )
#ssh
self.txt_ssh_host.setText( QString.fromUtf8( self.config.get_ssh_host() ) )
self.txt_ssh_port.setText( QString.fromUtf8( str(self.config.get_ssh_port()) ) )
self.txt_ssh_user.setText( QString.fromUtf8( self.config.get_ssh_user() ) )
self.txt_ssh_path.setText( QString.fromUtf8( self.config.get_snapshots_path_ssh() ) )
self.set_combo_value( self.combo_ssh_cipher, self.config.get_ssh_cipher(), type = 'str' )
self.txt_ssh_private_key_file.setText( QString.fromUtf8( self.config.get_ssh_private_key_file() ) )
#local_encfs
if self.mode == 'local_encfs':
self.edit_snapshots_path.setText( QString.fromUtf8( self.config.get_local_encfs_path() ) )
## #dummy
## self.txt_dummy_host.setText( QString.fromUtf8( self.config.get_dummy_host() ) )
## self.txt_dummy_port.setText( QString.fromUtf8( self.config.get_dummy_port() ) )
## self.txt_dummy_user.setText( QString.fromUtf8( self.config.get_dummy_user() ) )
#password
password_1 = self.config.get_password( mode = self.mode, pw_id = 1, only_from_keyring = True )
password_2 = self.config.get_password( mode = self.mode, pw_id = 2, only_from_keyring = True )
if password_1 is None:
password_1 = ''
if password_2 is None:
password_2 = ''
self.txt_password_1.setText( QString.fromUtf8( password_1 ) )
self.txt_password_2.setText( QString.fromUtf8( password_2 ) )
self.cb_password_save.setChecked( self.keyring_supported and self.config.get_password_save( mode = self.mode ) )
self.cb_password_use_cache.setChecked( self.config.get_password_use_cache( mode = self.mode ) )
self.cb_auto_host_user_profile.setChecked( self.config.get_auto_host_user_profile() )
host, user, profile = self.config.get_host_user_profile()
self.txt_host.setText( QString.fromUtf8( host ) )
self.txt_user.setText( QString.fromUtf8( user ) )
self.txt_profile.setText( QString.fromUtf8( profile ) )
self.update_host_user_profile()
self.set_combo_value( self.combo_automatic_snapshots, self.config.get_automatic_backup_mode() )
self.set_combo_value( self.combo_automatic_snapshots_time, self.config.get_automatic_backup_time() )
self.set_combo_value( self.combo_automatic_snapshots_day, self.config.get_automatic_backup_day() )
self.set_combo_value( self.combo_automatic_snapshots_weekday, self.config.get_automatic_backup_weekday() )
self.txt_automatic_snapshots_time_custom.setText( self.config.get_custom_backup_time() )
self.sb_automatic_snapshots_anacron_period.setValue(self.config.get_automatic_backup_anacron_period())
self.update_automatic_snapshot_time( self.config.get_automatic_backup_mode() )
#TAB: Include
self.list_include.clear()
for include in self.config.get_include():
self.add_include( include )
#TAB: Exclude
self.list_exclude.clear()
for exclude in self.config.get_exclude():
self.add_exclude( exclude )
#TAB: Auto-remove
#remove old snapshots
enabled, value, unit = self.config.get_remove_old_snapshots()
self.cb_remove_older_then.setChecked( enabled )
self.edit_remove_older_then.setValue( value )
self.set_combo_value( self.combo_remove_older_then, unit )
#min free space
enabled, value, unit = self.config.get_min_free_space()
self.cb_min_free_space.setChecked( enabled )
self.edit_min_free_space.setValue( value )
self.set_combo_value( self.combo_min_free_space, unit )
#min free inodes
self.cb_min_free_inodes.setChecked(self.config.min_free_inodes_enabled())
self.edit_min_free_inodes.setValue(self.config.min_free_inodes())
#smart remove
smart_remove, keep_all, keep_one_per_day, keep_one_per_week, keep_one_per_month = self.config.get_smart_remove()
self.cb_smart_remove.setChecked( smart_remove )
self.edit_keep_all.setValue( keep_all )
self.edit_keep_one_per_day.setValue( keep_one_per_day )
self.edit_keep_one_per_week.setValue( keep_one_per_week )
self.edit_keep_one_per_month.setValue( keep_one_per_month )
#don't remove named snapshots
self.cb_dont_remove_named_snapshots.setChecked( self.config.get_dont_remove_named_snapshots() )
#TAB: Options
self.cb_notify_enabled.setChecked( self.config.is_notify_enabled() )
self.cb_backup_on_restore.setChecked( self.config.is_backup_on_restore_enabled() )
self.cb_continue_on_errors.setChecked( self.config.continue_on_errors() )
self.cb_use_checksum.setChecked( self.config.use_checksum() )
self.cb_full_rsync.setChecked( self.config.full_rsync() )
self.update_check_for_changes()
self.cb_check_for_changes.setChecked( self.config.check_for_changes() )
self.set_combo_value( self.combo_log_level, self.config.log_level() )
#TAB: Expert Options
#self.cb_per_diretory_schedule.setChecked( self.config.get_per_directory_schedule() )
self.cb_run_nice_from_cron.setChecked( self.config.is_run_nice_from_cron_enabled() )
self.cb_run_ionice_from_cron.setChecked( self.config.is_run_ionice_from_cron_enabled() )
self.cb_run_ionice_from_user.setChecked( self.config.is_run_ionice_from_user_enabled() )
self.cb_run_nice_on_remote.setChecked(self.config.is_run_nice_on_remote_enabled())
self.cb_run_ionice_on_remote.setChecked(self.config.is_run_ionice_on_remote_enabled())
self.cb_bwlimit.setChecked( self.config.bwlimit_enabled() )
self.sb_bwlimit.setValue( self.config.bwlimit() )
self.cb_no_on_battery.setChecked( self.config.is_no_on_battery_enabled() )
self.cb_preserve_acl.setChecked( self.config.preserve_acl() )
self.cb_preserve_xattr.setChecked( self.config.preserve_xattr() )
self.cb_copy_unsafe_links.setChecked( self.config.copy_unsafe_links() )
self.cb_copy_links.setChecked( self.config.copy_links() )
#update
#self.update_include_columns()
self.update_remove_older_than()
self.update_min_free_space()
def save_profile( self ):
if self.combo_automatic_snapshots.itemData( self.combo_automatic_snapshots.currentIndex() ).toInt()[0] == self.config.CUSTOM_HOUR:
if not tools.check_cron_pattern(str( self.txt_automatic_snapshots_time_custom.text().toUtf8() ) ):
self.error_handler( _('Custom Hours can only be a comma seperate list of hours (e.g. 8,12,18,23) or */3 for periodic backups every 3 hours') )
return False
#mode
mode = str( self.combo_modes.itemData( self.combo_modes.currentIndex() ).toString().toUtf8() )
self.config.set_snapshots_mode( mode )
mount_kwargs = {}
#password
password_1 = str( self.txt_password_1.text().toUtf8() )
password_2 = str( self.txt_password_2.text().toUtf8() )
#ssh
ssh_host = str( self.txt_ssh_host.text().toUtf8() )
ssh_port = str( self.txt_ssh_port.text().toUtf8() )
ssh_user = str( self.txt_ssh_user.text().toUtf8() )
ssh_path = str( self.txt_ssh_path.text().toUtf8() )
ssh_cipher = str( self.combo_ssh_cipher.itemData( self.combo_ssh_cipher.currentIndex() ).toString().toUtf8() )
ssh_private_key_file = str( self.txt_ssh_private_key_file.text().toUtf8() )
if mode == 'ssh':
mount_kwargs = {'host': ssh_host,
'port': int(ssh_port),
'user': ssh_user,
'path': ssh_path,
'cipher': ssh_cipher,
'private_key_file': ssh_private_key_file,
'password': password_1
}
#local-encfs settings
local_encfs_path = str( self.edit_snapshots_path.text().toUtf8() )
if mode == 'local_encfs':
mount_kwargs = {'path': local_encfs_path,
'password': password_1
}
#ssh_encfs settings
if mode == 'ssh_encfs':
mount_kwargs = {'host': ssh_host,
'port': int(ssh_port),
'user': ssh_user,
'ssh_path': ssh_path,
'cipher': ssh_cipher,
'private_key_file': ssh_private_key_file,
'ssh_password': password_1,
'encfs_password': password_2
}
## #dummy
## dummy_host = str( self.txt_dummy_host.text().toUtf8() )
## dummy_port = str( self.txt_dummy_port.text().toUtf8() )
## dummy_user = str( self.txt_dummy_user.text().toUtf8() )
## if mode == 'dummy':
## #values must have exactly the same Type (str, int or bool)
## #as they are set in config or you will run into false-positive
## #HashCollision warnings
## mount_kwargs = {'host': dummy_host,
## 'port': int(dummy_port),
## 'user': dummy_user,
## 'password': password_1
## }
if not self.config.SNAPSHOT_MODES[mode][0] is None:
#pre_mount_check
mnt = mount.Mount(cfg = self.config, tmp_mount = True, parent = self)
try:
mnt.pre_mount_check(mode = mode, first_run = True, **mount_kwargs)
except mount.MountException as ex:
self.error_handler(str(ex))
return False
#okay, lets try to mount
try:
hash_id = mnt.mount(mode = mode, check = False, **mount_kwargs)
except mount.MountException as ex:
self.error_handler(str(ex))
return False
#snapshots path
self.config.set_auto_host_user_profile( self.cb_auto_host_user_profile.isChecked() )
self.config.set_host_user_profile(
str( self.txt_host.text().toUtf8() ),
str( self.txt_user.text().toUtf8() ),
str( self.txt_profile.text().toUtf8() ) )
if self.config.SNAPSHOT_MODES[mode][0] is None:
snapshots_path = str( self.edit_snapshots_path.text().toUtf8() )
else:
snapshots_path = self.config.get_snapshots_path(mode = mode, tmp_mount = True)
self.config.set_snapshots_path( snapshots_path, mode = mode )
#save ssh
self.config.set_ssh_host(ssh_host)
self.config.set_ssh_port(ssh_port)
self.config.set_ssh_user(ssh_user)
self.config.set_snapshots_path_ssh(ssh_path)
self.config.set_ssh_cipher(ssh_cipher)
self.config.set_ssh_private_key_file(ssh_private_key_file)
#save local_encfs
self.config.set_local_encfs_path(local_encfs_path)
## #save dummy
## self.config.set_dummy_host(dummy_host)
## self.config.set_dummy_port(dummy_port)
## self.config.set_dummy_user(dummy_user)
#save password
self.config.set_password_save(self.cb_password_save.isChecked(), mode = mode)
self.config.set_password_use_cache(self.cb_password_use_cache.isChecked(), mode = mode)
self.config.set_password(password_1, mode = mode)
self.config.set_password(password_2, mode = mode, pw_id = 2)
#include list
include_list = []
for index in xrange( self.list_include.topLevelItemCount() ):
item = self.list_include.topLevelItem( index )
#include_list.append( [ str( item.text(0).toUtf8() ), item.data( 0, Qt.UserRole ).toInt()[0] ] )
include_list.append( ( str( item.text(0).toUtf8() ), item.data( 0, Qt.UserRole ).toInt()[0] ) )
self.config.set_include( include_list )
#exclude patterns
exclude_list = []
for index in xrange( self.list_exclude.count() ):
exclude_list.append( str( self.list_exclude.item( index ).text().toUtf8() ) )
self.config.set_exclude( exclude_list )
#schedule
self.config.set_automatic_backup_mode( self.combo_automatic_snapshots.itemData( self.combo_automatic_snapshots.currentIndex() ).toInt()[0] )
self.config.set_automatic_backup_time( self.combo_automatic_snapshots_time.itemData( self.combo_automatic_snapshots_time.currentIndex() ).toInt()[0] )
self.config.set_automatic_backup_weekday( self.combo_automatic_snapshots_weekday.itemData( self.combo_automatic_snapshots_weekday.currentIndex() ).toInt()[0] )
self.config.set_automatic_backup_day( self.combo_automatic_snapshots_day.itemData( self.combo_automatic_snapshots_day.currentIndex() ).toInt()[0] )
self.config.set_custom_backup_time( str( self.txt_automatic_snapshots_time_custom.text().toUtf8() ) )
self.config.set_automatic_backup_anacron_period(self.sb_automatic_snapshots_anacron_period.value())
#auto-remove
self.config.set_remove_old_snapshots(
self.cb_remove_older_then.isChecked(),
self.edit_remove_older_then.value(),
self.combo_remove_older_then.itemData( self.combo_remove_older_then.currentIndex() ).toInt()[0] )
self.config.set_min_free_space(
self.cb_min_free_space.isChecked(),
self.edit_min_free_space.value(),
self.combo_min_free_space.itemData( self.combo_min_free_space.currentIndex() ).toInt()[0] )
self.config.set_min_free_inodes(
self.cb_min_free_inodes.isChecked(),
self.edit_min_free_inodes.value() )
self.config.set_dont_remove_named_snapshots( self.cb_dont_remove_named_snapshots.isChecked() )
self.config.set_smart_remove(
self.cb_smart_remove.isChecked(),
self.edit_keep_all.value(),
self.edit_keep_one_per_day.value(),
self.edit_keep_one_per_week.value(),
self.edit_keep_one_per_month.value() )
#options
self.config.set_notify_enabled( self.cb_notify_enabled.isChecked() )
self.config.set_backup_on_restore( self.cb_backup_on_restore.isChecked() )
self.config.set_continue_on_errors( self.cb_continue_on_errors.isChecked() )
self.config.set_use_checksum( self.cb_use_checksum.isChecked() )
self.config.set_full_rsync( self.cb_full_rsync.isChecked() )
self.config.set_check_for_changes( self.cb_check_for_changes.isChecked() )
self.config.set_log_level( self.combo_log_level.itemData( self.combo_log_level.currentIndex() ).toInt()[0] )
#expert options
#self.config.set_per_directory_schedule( self.cb_per_diretory_schedule.isChecked() )
self.config.set_run_nice_from_cron_enabled( self.cb_run_nice_from_cron.isChecked() )
self.config.set_run_ionice_from_cron_enabled( self.cb_run_ionice_from_cron.isChecked() )
self.config.set_run_ionice_from_user_enabled( self.cb_run_ionice_from_user.isChecked() )
self.config.set_run_nice_on_remote_enabled(self.cb_run_nice_on_remote.isChecked())
self.config.set_run_ionice_on_remote_enabled(self.cb_run_ionice_on_remote.isChecked())
self.config.set_bwlimit_enabled( self.cb_bwlimit.isChecked() )
self.config.set_bwlimit( self.sb_bwlimit.value() )
self.config.set_no_on_battery_enabled( self.cb_no_on_battery.isChecked() )
self.config.set_preserve_acl( self.cb_preserve_acl.isChecked() )
self.config.set_preserve_xattr( self.cb_preserve_xattr.isChecked() )
self.config.set_copy_unsafe_links( self.cb_copy_unsafe_links.isChecked() )
self.config.set_copy_links( self.cb_copy_links.isChecked() )
#umount
if not self.config.SNAPSHOT_MODES[mode][0] is None:
try:
mnt.umount(hash_id = hash_id)
except mount.MountException as ex:
self.error_handler(str(ex))
return False
return True
def error_handler( self, message ):
KMessageBox.error( self, QString.fromUtf8( message ) )
def question_handler( self, message ):
return KMessageBox.Yes == KMessageBox.warningYesNo( self, QString.fromUtf8( message ) )
def exec_( self ):
self.config.set_question_handler( self.question_handler )
self.config.set_error_handler( self.error_handler )
ret_val = KDialog.exec_( self )
self.config.clear_handlers()
if ret_val != QDialog.Accepted:
self.config.dict = self.config_copy_dict
self.config.set_current_profile( self.current_profile_org )
return ret_val
def update_snapshots_location( self ):
'''Update snapshot location dialog'''
self.config.set_question_handler( self.question_handler )
self.config.set_error_handler( self.error_handler )
self.snapshots.update_snapshots_location()
#def update_include_columns( self ):
# if self.cb_per_diretory_schedule.isChecked():
# self.list_include.showColumn( 1 )
# self.global_schedule_group_box.hide()
# else:
# self.list_include.hideColumn( 1 )
# self.global_schedule_group_box.show()
#def on_list_include_item_activated( self, item, column ):
# if not self.cb_per_diretory_schedule.isChecked():
# return
#
# if item is None:
# return
# #if column != 1:
# # return
# self.popup_automatic_backup.popup( QCursor.pos() )
#def on_popup_automatic_backup( self ):
# print "ABC"
def update_remove_older_than( self ):
enabled = self.cb_remove_older_then.isChecked()
self.edit_remove_older_then.setEnabled( enabled )
self.combo_remove_older_then.setEnabled( enabled )
def update_min_free_space( self ):
enabled = self.cb_min_free_space.isChecked()
self.edit_min_free_space.setEnabled( enabled )
self.combo_min_free_space.setEnabled( enabled )
def update_min_free_inodes(self):
enabled = self.cb_min_free_inodes.isChecked()
self.edit_min_free_inodes.setEnabled(enabled)
def add_include( self, data ):
item = QTreeWidgetItem()
if data[1] == 0:
item.setIcon( 0, KIcon('folder') )
else:
item.setIcon( 0, KIcon('text-plain') )
item.setText( 0, QString.fromUtf8( data[0] ) )
#item.setText( 0, QString.fromUtf8( data[0] ) )
#item.setText( 1, QString.fromUtf8( self.config.AUTOMATIC_BACKUP_MODES[ data[1] ] ) )
item.setData( 0, Qt.UserRole, QVariant( data[1] ) )
self.list_include.addTopLevelItem( item )
if self.list_include.currentItem() is None:
self.list_include.setCurrentItem( item )
return item
def add_exclude( self, pattern ):
item = QListWidgetItem( KIcon('edit-delete'), QString.fromUtf8( pattern ), self.list_exclude )
if self.list_exclude.currentItem() is None:
self.list_exclude.setCurrentItem( item )
return item
def fill_combo( self, combo, dict ):
keys = dict.keys()
keys.sort()
for key in keys:
combo.addItem( QIcon(), QString.fromUtf8( dict[ key ] ), QVariant( key ) )
def set_combo_value( self, combo, value, type = 'int' ):
for i in xrange( combo.count() ):
if type == 'int' and value == combo.itemData( i ).toInt()[0]:
combo.setCurrentIndex( i )
break
if type == 'str' and value == combo.itemData( i ).toString():
combo.setCurrentIndex( i )
break
def validate( self ):
if not self.save_profile():
return False
if not self.config.check_config():
return False
if not self.config.setup_cron():
return False
self.config.save()
return True
def on_btn_exclude_remove_clicked ( self ):
for item in self.list_exclude.selectedItems():
self.list_exclude.takeItem(self.list_exclude.row(item))
if self.list_exclude.count() > 0:
self.list_exclude.setCurrentItem( self.list_exclude.item(0) )
def add_exclude_( self, pattern ):
if len( pattern ) == 0:
return
for index in xrange( self.list_exclude.count() ):
if pattern == self.list_exclude.item( index ).text().toUtf8():
return
self.add_exclude( pattern )
def on_btn_exclude_add_clicked( self ):
ret_val = KInputDialog.getText( QString.fromUtf8( _( 'Exclude pattern' ) ), '', '', self )
if not ret_val[1]:
return
pattern = str( ret_val[0].toUtf8() ).strip()
if len( pattern ) == 0:
return
if pattern.find( ':' ) >= 0:
KMessageBox.error( self, QString.fromUtf8( _('Exclude patterns can\'t contain \':\' char !') ) )
return
self.add_exclude_( pattern )
def on_btn_exclude_file_clicked( self ):
for path in KFileDialog.getOpenFileNames( KUrl(), '', self, QString.fromUtf8( _( 'Exclude file' ) ) ):
self.add_exclude_( str(path.toUtf8()) )
def on_btn_exclude_folder_clicked( self ):
dialog = kde4tools.getExistingDirectories( self, QString.fromUtf8( _( 'Exclude folder' ) ) )
if dialog.exec_():
for path in dialog.selectedFiles():
self.add_exclude_( str(path.toUtf8()) )
def on_btn_include_remove_clicked ( self ):
for item in self.list_include.selectedItems():
index = self.list_include.indexOfTopLevelItem( item )
if index < 0:
continue
self.list_include.takeTopLevelItem( index )
if self.list_include.topLevelItemCount() > 0:
self.list_include.setCurrentItem( self.list_include.topLevelItem(0) )
def on_btn_include_file_add_clicked( self ):
for path in KFileDialog.getOpenFileNames( KUrl(), '', self, QString.fromUtf8( _( 'Include file' ) ) ):
path = str(path.toUtf8())
if len( path ) == 0 :
continue
path = self.config.prepare_path( path )
for index in xrange( self.list_include.topLevelItemCount() ):
if path == str( self.list_include.topLevelItem( index ).text( 0 ).toUtf8() ):
continue
self.add_include( ( path, 1 ) )
def on_btn_include_add_clicked( self ):
dialog = kde4tools.getExistingDirectories( self, QString.fromUtf8( _( 'Include folder' ) ) )
if dialog.exec_():
for path in dialog.selectedFiles():
path = str(path.toUtf8())
if len( path ) == 0 :
continue
path = self.config.prepare_path( path )
for index in xrange( self.list_include.topLevelItemCount() ):
if path == str( self.list_include.topLevelItem( index ).text( 0 ).toUtf8() ):
continue
self.add_include( ( path, 0 ) )
def on_btn_snapshots_path_clicked( self ):
old_path = str( self.edit_snapshots_path.text().toUtf8() )
path = str( KFileDialog.getExistingDirectory( KUrl( self.edit_snapshots_path.text() ), self, QString.fromUtf8( _( 'Where to save snapshots' ) ) ).toUtf8() )
if len( path ) > 0 :
if len( old_path ) > 0 and old_path != path:
if not self.question_handler( _('Are you sure you want to change snapshots folder ?') ):
return
self.edit_snapshots_path.setText( QString.fromUtf8( self.config.prepare_path( path ) ) )
def on_btn_ssh_private_key_file_clicked( self ):
old_file = str( self.txt_ssh_private_key_file.text().toUtf8() )
if len(old_file) > 0:
start_dir = KUrl( self.txt_ssh_private_key_file.text() )
else:
start_dir = KUrl( self.config.get_ssh_private_key_folder() )
file = str( KFileDialog.getOpenFileName( start_dir, QString.fromUtf8(''), self, QString.fromUtf8( _( 'SSH private key' ) ) ).toUtf8() )
if len( file ) > 0 :
self.txt_ssh_private_key_file.setText( QString.fromUtf8( self.config.prepare_path( file ) ) )
def on_combo_modes_changed(self, *params):
if len(params) == 0:
index = self.combo_modes.currentIndex()
else:
index = params[0]
active_mode = str( self.combo_modes.itemData( index ).toString().toUtf8() )
if active_mode != self.mode:
for mode in self.config.SNAPSHOT_MODES.keys():
getattr(self, 'mode_%s' % mode).hide()
for mode in self.config.SNAPSHOT_MODES.keys():
if active_mode == mode:
getattr(self, 'mode_%s' % mode).show()
self.mode = active_mode
if self.config.mode_need_password(active_mode):
self.lbl_password_1.setText( QString.fromUtf8( self.config.SNAPSHOT_MODES[active_mode][2] + ':' ) )
self.frame_password_1.show()
if self.config.mode_need_password(active_mode, 2):
self.lbl_password_2.setText( QString.fromUtf8( self.config.SNAPSHOT_MODES[active_mode][3] + ':' ) )
self.lbl_password_2.show()
self.txt_password_2.show()
kde4tools.equal_indent(self.lbl_password_1, self.lbl_password_2)
else:
self.lbl_password_2.hide()
self.txt_password_2.hide()
kde4tools.equal_indent(self.lbl_password_1)
else:
self.frame_password_1.hide()
if active_mode == 'ssh_encfs':
self.lbl_ssh_encfs_exclude_warning.show()
else:
self.lbl_ssh_encfs_exclude_warning.hide()
enabled = active_mode in ('ssh', 'ssh_encfs')
self.cb_run_nice_on_remote.setEnabled(enabled)
self.cb_run_ionice_on_remote.setEnabled(enabled)
self.cb_bwlimit.setEnabled(enabled)
self.sb_bwlimit.setEnabled(enabled)
def accept( self ):
if self.validate():
KDialog.accept( self )
|