本文整理汇总了Python中settings.Settings.save方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.save方法的具体用法?Python Settings.save怎么用?Python Settings.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_settings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
def create_settings():
SETTINGS_FILE = "oacp_conf.json"
settings = Settings(SETTINGS_FILE)
DefaultSettings.populate(settings)
settings.load()
settings.save()
return settings
示例2: post
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
def post(self):
if is_admin:
parm = utf8(self.request.get('parm'))
value = utf8(self.request.get('value'))
Settings.save(parm, value)
self.redirect('/settings')
else:
self.error(401)
self.response.out.write('Access Denied')
示例3: testCreateSettingsFile
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
def testCreateSettingsFile(self):
"""Tests that instantiating and saving a Settings creates the settings
file if it doesn't exist.
"""
if os.path.isfile('cocoman.conf'):
self.fail("A file already exists with the same name the test was going"
+ " to use. Please remove it.")
settings = Settings()
settings.save('cocoman.conf')
assert(os.path.isfile('cocoman.conf') is True)
os.remove('cocoman.conf')
示例4: settings_button_clicked
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
def settings_button_clicked(self):
s = SettingsDialog(self)
ret = s.exec_()
if ret == 1:
Settings.save(s.settings)
self.settings = Settings.read()
self.refresh_shortcuts()
示例5: set_setting
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
def set_setting(setting_name, setting_value):
settings = Settings()
if setting_name == "registry-server":
settings.set_registry_server(setting_value)
elif setting_name == "repository-server":
settings.set_repository_server(setting_value)
elif setting_name == "project":
settings.set_current_project(setting_value)
else:
raise Exception("invalid setting")
settings.save()
示例6: save
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
def save(self):
try:
os.mkdir(os.curdir + "/saves")
except:
pass
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime("%Y%m%d%H%M%S")
filename = os.curdir + "/saves/mandelbrot_" + st
file = open(filename, "w")
set = Settings()
set.save(self)
set.to_file(file)
return filename
示例7: test_basic
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
def test_basic(self):
wSetting = Settings()
wSetting['test0'] = 'hello'
wSetting['test1'] = 10
wSetting['test2'] = [0, 2, 3]
self.assertEqual(wSetting.get('test3', 3), 3)
self.assertEqual(wSetting.save(), True)
示例8: AutoCanaryGui
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
#.........这里部分代码省略.........
status_options = ["All good", "It's complicated"]
for option in status_options:
self.status.addItem(option)
option = self.settings.get_status()
if option in status_options:
self.status.setCurrentIndex(status_options.index(option))
self.status_layout.addWidget(self.status_label)
self.status_layout.addWidget(self.status)
# canary text box
self.textbox = QtGui.QTextEdit()
self.textbox.setText(self.settings.get_text())
# key selection
seckeys = gpg.seckeys_list()
self.key_selection = QtGui.QComboBox()
for seckey in seckeys:
uid = seckey['uid']
if len(uid) >= 53:
uid = '{0}...'.format(uid[:50])
fp = seckey['fp'][-8:]
text = '{0} [{1}]'.format(uid, fp)
self.key_selection.addItem(text)
fp = self.settings.get_fp()
if fp:
key_i = 0
for i, seckey in enumerate(seckeys):
if seckey['fp'] == fp:
key_i = i
self.key_selection.setCurrentIndex(key_i)
# buttons
self.buttons_layout = QtGui.QHBoxLayout()
self.sign_save_button = QtGui.QPushButton('Save and Sign')
self.sign_save_button.clicked.connect(self.sign_save_clicked)
self.sign_once = QtGui.QPushButton('One-Time Sign')
self.sign_once.clicked.connect(self.sign_once_clicked)
self.buttons_layout.addWidget(self.sign_save_button)
self.buttons_layout.addWidget(self.sign_once)
# layout
self.layout = QtGui.QVBoxLayout()
self.layout.addLayout(self.date_layout)
self.layout.addLayout(self.status_layout)
self.layout.addWidget(self.textbox)
self.layout.addWidget(self.key_selection)
self.layout.addLayout(self.buttons_layout)
self.setLayout(self.layout)
self.show()
def update_date(self):
frequency = self.frequency.currentText()
year = self.year.currentText()
if frequency == 'Weekly':
self.weekly_label.show()
self.weekly_dropdown.show()
# regenerate the weekly dropdown options based on the current year
self.weekly_dropdown.clear()
one_week = datetime.timedelta(7)
cur_date = datetime.datetime(int(year), 1, 1)
def get_monday_of_week(d):
days_past = d.isoweekday() - 1
示例9: Settings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
cfg = Settings()
# Get filename here.
fileitem = form['filename']
fname = f['title']
# Test if the file was uploaded
if fileitem.filename:
# strip leading path from file name to avoid
# directory traversal attacks
fn = os.path.basename(fileitem.filename)
path = '/var/www/schedule/' + fname + '.csv'
open(path, 'wb').write(fileitem.file.read())
cfg.addSchedule(fname, path)
cfg.save()
message = 'The file "' + fn + '" was uploaded successfully'
else:
message = 'No file was uploaded'
print """\
Content-Type: text/html\n
<html>
<head>
<meta http-equiv='refresh' content='5; url=/settings.html'>
</head>
<body>
<p>%s</p>
</body>
</html>
示例10: FrameMain
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
#.........这里部分代码省略.........
self.menuStopEnd = menuScan.Append(wx.ID_ANY, "Stop at &end",
"Complete current sweep "
"before stopping")
menuTools = wx.Menu()
self.menuCompare = menuTools.Append(wx.ID_ANY, "&Compare...",
"Compare plots")
self.menuCal = menuTools.Append(wx.ID_ANY, "&Auto Calibration...",
"Automatically calibrate to a known frequency")
menuHelp = wx.Menu()
menuHelpLink = menuHelp.Append(wx.ID_HELP, "&Help...",
"Link to help")
menuHelp.AppendSeparator()
menuUpdate = menuHelp.Append(wx.ID_ANY, "&Check for updates...",
"Check for updates to the program")
menuHelp.AppendSeparator()
menuAbout = menuHelp.Append(wx.ID_ABOUT, "&About...",
"Information about this program")
menuBar = wx.MenuBar()
menuBar.Append(menuFile, "&File")
menuBar.Append(menuEdit, "&Edit")
menuBar.Append(menuView, "&View")
menuBar.Append(menuScan, "&Scan")
menuBar.Append(menuTools, "&Tools")
menuBar.Append(menuHelp, "&Help")
self.SetMenuBar(menuBar)
self.Bind(wx.EVT_MENU, self.__on_new, self.menuNew)
self.Bind(wx.EVT_MENU, self.__on_open, self.menuOpen)
self.Bind(wx.EVT_MENU_RANGE, self.__on_file_history, id=wx.ID_FILE1,
id2=wx.ID_FILE9)
self.Bind(wx.EVT_MENU, self.__on_save, self.menuSave)
self.Bind(wx.EVT_MENU, self.__on_export_scan, self.menuExportScan)
self.Bind(wx.EVT_MENU, self.__on_export_image, self.menuExportImage)
self.Bind(wx.EVT_MENU, self.__on_export_geo, self.menuExportGeo)
self.Bind(wx.EVT_MENU, self.__on_page, self.menuPage)
self.Bind(wx.EVT_MENU, self.__on_preview, self.menuPreview)
self.Bind(wx.EVT_MENU, self.__on_print, self.menuPrint)
self.Bind(wx.EVT_MENU, self.__on_properties, self.menuProperties)
self.Bind(wx.EVT_MENU, self.__on_exit, menuExit)
self.Bind(wx.EVT_MENU, self.__on_pref, self.menuPref)
self.Bind(wx.EVT_MENU, self.__on_adv_pref, self.menuAdvPref)
self.Bind(wx.EVT_MENU, self.__on_devices_rtl, self.menuDevicesRtl)
self.Bind(wx.EVT_MENU, self.__on_devices_gps, self.menuDevicesGps)
self.Bind(wx.EVT_MENU, self.__on_reset, self.menuReset)
self.Bind(wx.EVT_MENU, self.__on_clear_select, self.menuClearSelect)
self.Bind(wx.EVT_MENU, self.__on_show_measure, self.menuShowMeasure)
self.Bind(wx.EVT_MENU, self.__on_start, self.menuStart)
self.Bind(wx.EVT_MENU, self.__on_stop, self.menuStop)
self.Bind(wx.EVT_MENU, self.__on_stop_end, self.menuStopEnd)
self.Bind(wx.EVT_MENU, self.__on_compare, self.menuCompare)
self.Bind(wx.EVT_MENU, self.__on_cal, self.menuCal)
self.Bind(wx.EVT_MENU, self.__on_about, menuAbout)
self.Bind(wx.EVT_MENU, self.__on_help, menuHelpLink)
self.Bind(wx.EVT_MENU, self.__on_update, menuUpdate)
idF1 = wx.wx.NewId()
self.Bind(wx.EVT_MENU, self.__on_help, id=idF1)
accelTable = wx.AcceleratorTable([(wx.ACCEL_NORMAL, wx.WXK_F1, idF1)])
self.SetAcceleratorTable(accelTable)
def __create_popup_menu(self):
self.popupMenu = wx.Menu()
self.popupMenuStart = self.popupMenu.Append(wx.ID_ANY, "&Start",
示例11: FrameMain
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
#.........这里部分代码省略.........
self.menuStop = menuScan.Append(wx.ID_ANY, "S&top",
"Stop scan immediately")
self.menuStopEnd = menuScan.Append(wx.ID_ANY, "Stop at &end",
"Complete current sweep "
"before stopping")
menuView = wx.Menu()
self.menuPref = menuView.Append(wx.ID_ANY, "&Preferences...",
"Preferences")
menuTools = wx.Menu()
self.menuCompare = menuTools.Append(wx.ID_ANY, "&Compare...",
"Compare plots")
self.menuCal = menuTools.Append(wx.ID_ANY, "&Auto Calibration...",
"Automatically calibrate to a known frequency")
menuHelp = wx.Menu()
menuHelpLink = menuHelp.Append(wx.ID_HELP, "&Help...",
"Link to help")
menuAbout = menuHelp.Append(wx.ID_ABOUT, "&About...",
"Information about this program")
menuBar = wx.MenuBar()
menuBar.Append(menuFile, "&File")
menuBar.Append(menuScan, "&Scan")
menuBar.Append(menuView, "&View")
menuBar.Append(menuTools, "&Tools")
menuBar.Append(menuHelp, "&Help")
self.SetMenuBar(menuBar)
self.Bind(wx.EVT_MENU, self.on_open, self.menuOpen)
self.Bind(wx.EVT_MENU_RANGE, self.on_file_history, id=wx.ID_FILE1,
id2=wx.ID_FILE9)
self.Bind(wx.EVT_MENU, self.on_save, self.menuSave)
self.Bind(wx.EVT_MENU, self.on_export, self.menuExport)
self.Bind(wx.EVT_MENU, self.on_properties, self.menuProperties)
self.Bind(wx.EVT_MENU, self.on_exit, menuExit)
self.Bind(wx.EVT_MENU, self.on_start, self.menuStart)
self.Bind(wx.EVT_MENU, self.on_stop, self.menuStop)
self.Bind(wx.EVT_MENU, self.on_stop_end, self.menuStopEnd)
self.Bind(wx.EVT_MENU, self.on_pref, self.menuPref)
self.Bind(wx.EVT_MENU, self.on_compare, self.menuCompare)
self.Bind(wx.EVT_MENU, self.on_cal, self.menuCal)
self.Bind(wx.EVT_MENU, self.on_about, menuAbout)
self.Bind(wx.EVT_MENU, self.on_help, menuHelpLink)
idF1 = wx.wx.NewId()
self.Bind(wx.EVT_MENU, self.on_help, id=idF1)
accelTable = wx.AcceleratorTable([(wx.ACCEL_NORMAL, wx.WXK_F1, idF1)])
self.SetAcceleratorTable(accelTable)
def create_popup_menu(self):
self.popupMenu = wx.Menu()
self.popupMenuStart = self.popupMenu.Append(wx.ID_ANY, "&Start",
"Start scan")
self.popupMenuStop = self.popupMenu.Append(wx.ID_ANY, "S&top",
"Stop scan immediately")
self.popupMenuStopEnd = self.popupMenu.Append(wx.ID_ANY, "Stop at &end",
"Complete current sweep "
"before stopping")
self.Bind(wx.EVT_MENU, self.on_start, self.popupMenuStart)
self.Bind(wx.EVT_MENU, self.on_stop, self.popupMenuStop)
self.Bind(wx.EVT_MENU, self.on_stop_end, self.popupMenuStopEnd)
self.Bind(wx.EVT_CONTEXT_MENU, self.on_popup_menu)
示例12: LockinGui
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
class LockinGui(object):
_window_title = "Lock-in Spectrum"
_heartbeat = 100 # ms delay at which the plot/gui is refreshed, and the gamepad moves the stage
def __init__(self):
self.savedir = "./Spectra/"
self.path = "./"
self.settings = Settings()
self.x_step = .0
self.y_step = .0
self.step_distance = 1 # in um
try:
self.stage = PIStage.E545(self.settings.stage_ip,self.settings.stage_port)
except:
self.stage = None
self.stage = PIStage.Dummy()
print("Could not initialize PIStage, using Dummy instead")
GObject.threads_init()
# only GObject.idle_add() is in the background thread
self.window = Gtk.Window(title=self._window_title)
# self.window.set_resizable(False)
self.window.set_border_width(3)
self.grid = Gtk.Grid()
self.grid.set_row_spacing(5)
self.grid.set_column_spacing(5)
self.window.add(self.grid)
# Buttons for spectrum stack
self.button_live = Gtk.Button(label="Liveview")
self.button_live.set_tooltip_text("Start/Stop Liveview of Spectrum")
self.button_stop = Gtk.Button(label="Stop")
self.button_stop.set_tooltip_text("Stop any ongoing Action")
self.button_stop.set_sensitive(False)
self.button_aquire = Gtk.Button(label="Aquire Spectrum")
self.button_aquire.set_tooltip_text("Start/Stop aquiring Lock-In Spectrum")
self.button_direction = Gtk.Button(label="Set Direction")
self.button_direction.set_tooltip_text("Set Direction of Stage Movement")
self.button_settings = Gtk.Button(label="Settings")
self.button_settings.set_tooltip_text("Set Integration Time and Number of Samples")
self.button_search = Gtk.Button(label="Search for Max")
self.button_search.set_tooltip_text("Search for position with maximum Intensity")
self.button_save = Gtk.Button(label="Save Data")
self.button_save.set_tooltip_text("Save all spectral Data in .csv")
self.button_dark = Gtk.Button(label="Take Dark Spectrum")
self.button_dark.set_tooltip_text("Take dark spectrum which will substracted from spectrum")
self.button_lamp = Gtk.Button(label="Take Lamp Spectrum")
self.button_lamp.set_tooltip_text("Take lamp spectrum to normalize spectrum")
self.button_normal = Gtk.Button(label="Take Normal Spectrum")
self.button_normal.set_tooltip_text("Start/Stop taking a normal spectrum")
self.button_bg = Gtk.Button(label="Take Background Spectrum")
self.button_bg.set_tooltip_text("Start/Stop taking a Background spectrum")
self.button_series = Gtk.Button(label="Take Time Series")
self.button_series.set_tooltip_text("Start/Stop taking a Time Series of Spectra")
self.button_reset = Gtk.Button(label="Reset")
self.button_reset.set_tooltip_text("Reset all spectral data (if not saved data is lost!)")
self.button_loaddark = Gtk.Button(label="Load Dark Spectrum")
self.button_loaddark.set_tooltip_text("Load Dark Spectrum from file")
self.button_loadlamp = Gtk.Button(label="Load Lamp Spectrum")
self.button_loadlamp.set_tooltip_text("Load Lamp Spectrum from file")
# Stage Control Buttons
self.button_xup = Gtk.Button(label="x+")
self.button_xdown = Gtk.Button(label="x-")
self.button_yup = Gtk.Button(label="y+")
self.button_ydown = Gtk.Button(label="y-")
self.button_zup = Gtk.Button(label="z+")
self.button_zdown = Gtk.Button(label="z-")
self.button_stepup = Gtk.Button(label="+")
self.button_stepdown = Gtk.Button(label="-")
self.label_stepsize = Gtk.Label(label=str(self.settings.stepsize))
self.button_moverel = Gtk.Button(label="Move Stage rel.")
self.button_moveabs = Gtk.Button(label="Move Stage abs.")
# Stage position labels
self.label_x = Gtk.Label()
self.label_y = Gtk.Label()
self.label_z = Gtk.Label()
self.show_pos()
# Connect Buttons
self.window.connect("delete-event", self.quit)
self.button_aquire.connect("clicked", self.on_lockin_clicked)
self.button_direction.connect("clicked", self.on_direction_clicked)
self.button_live.connect("clicked", self.on_live_clicked)
self.button_stop.connect("clicked", self.on_stop_clicked)
self.button_settings.connect("clicked", self.on_settings_clicked)
self.button_search.connect("clicked", self.on_search_clicked)
self.button_save.connect("clicked", self.on_save_clicked)
self.button_dark.connect("clicked", self.on_dark_clicked)
self.button_lamp.connect("clicked", self.on_lamp_clicked)
self.button_normal.connect("clicked", self.on_normal_clicked)
self.button_bg.connect("clicked", self.on_bg_clicked)
self.button_series.connect("clicked", self.on_series_clicked)
self.button_reset.connect("clicked", self.on_reset_clicked)
self.button_loaddark.connect("clicked", self.on_loaddark_clicked)
self.button_loadlamp.connect("clicked", self.on_loadlamp_clicked)
#.........这里部分代码省略.........
示例13: set_settings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
def set_settings():
try:
Settings.save(datastorage, request.form)
return ''
except AttributeError:
abort(400)
示例14: shortcut_dropped
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
self.value_edited()
def shortcut_dropped(self, name, command, icon):
command = " ".join(i for i in command.split() if not i.startswith("%"))
self.shortcuts.append({
"name": name,
"command": command,
"icon": icon
})
self.refresh_shortcuts()
self.shortcuts_listwidget.setCurrentRow(
self.shortcuts_listwidget.count()-1
)
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
s = SettingsDialog()
ret = s.show()
if ret == 1:
Settings.save(s.settings)
app.exec_()
示例15: Settings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import save [as 别名]
from settings import Settings
SETTINGS = Settings()
SETTINGS.set("center_server", "127.0.0.1:8080", autosave=False, override=False)
SETTINGS.set("center_server2", "127.0.0.1:8080", autosave=False, override=False)
SETTINGS.set("mainframe position", (100, 50), autosave=False, override=False)
SETTINGS.set("mainframe size", (800, 600), autosave=False, override=False)
SETTINGS.set("lang", "cn", autosave=False, override=False)
SETTINGS.save()