在Jupyter中使用自定义ContentsManager创建新文件

时间:2019-12-30 15:09:07

标签: python jupyter-notebook jupyter jupyter-lab

我正在为Jupyter Notebook写一个自定义的ContentsManager管理器,然后开始创建新文件。

最初,我的<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1003</width> <height>703</height> </rect> </property> <property name="windowTitle"> <string>Mouse Pointer</string> </property> <property name="locale"> <locale language="English" country="UnitedKingdom"/> </property> <widget class="QWidget" name="centralwidget"> <layout class="QGridLayout" name="gridLayout_2"> <item row="3" column="0"> <layout class="QVBoxLayout" name="verticalLayout_bottom"/> </item> <item row="0" column="0"> <layout class="QVBoxLayout" name="verticalLayout_top"/> </item> <item row="1" column="0"> <layout class="QGridLayout" name="gridLayout"> <item row="2" column="1"> <widget class="QProgressBar" name="progressBar_y_plus"> <property name="maximum"> <number>1000</number> </property> <property name="value"> <number>0</number> </property> </widget> </item> <item row="1" column="1"> <widget class="QProgressBar" name="progressBar_x_minus"> <property name="maximum"> <number>1000</number> </property> <property name="value"> <number>0</number> </property> </widget> </item> <item row="0" column="1"> <widget class="QProgressBar" name="progressBar_x_plus"> <property name="maximum"> <number>1000</number> </property> <property name="value"> <number>0</number> </property> </widget> </item> <item row="3" column="0"> <widget class="QLabel" name="label_y_minus"> <property name="text"> <string>Y-</string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> </property> </widget> </item> <item row="0" column="0"> <widget class="QLabel" name="label_x_plus"> <property name="text"> <string>X+</string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> </property> </widget> </item> <item row="3" column="1"> <widget class="QProgressBar" name="progressBar_y_minus"> <property name="maximum"> <number>1000</number> </property> <property name="value"> <number>0</number> </property> </widget> </item> <item row="2" column="0"> <widget class="QLabel" name="label_y_plus"> <property name="text"> <string>Y+</string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> </property> </widget> </item> <item row="1" column="0"> <widget class="QLabel" name="label_x_minus"> <property name="text"> <string>X-</string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> </property> </widget> </item> <item row="4" column="1"> <widget class="QProgressBar" name="progressBar_w_plus"> <property name="maximum"> <number>10000</number> </property> <property name="value"> <number>0</number> </property> </widget> </item> <item row="5" column="1"> <widget class="QProgressBar" name="progressBar_w_minus"> <property name="maximum"> <number>10000</number> </property> <property name="value"> <number>0</number> </property> </widget> </item> <item row="4" column="0"> <widget class="QLabel" name="label_w_plus"> <property name="text"> <string>W+</string> </property> </widget> </item> <item row="5" column="0"> <widget class="QLabel" name="label_w_minus"> <property name="text"> <string>W-</string> </property> </widget> </item> </layout> </item> <item row="2" column="0"> <widget class="QPushButton" name="reset_button"> <property name="text"> <string>Reset bars</string> </property> </widget> </item> </layout> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1003</width> <height>24</height> </rect> </property> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> <connections/> </ui> 函数总是返回file_exists,并且出现True错误,与this issue相同。

在我修改了Cannot POST to files, use PUT instead函数以返回file_exists之后,Jupyter现在陷入了用以下命令调用False的循环中:

file_exists

我的问题是-我应该从/dir /dir/Untitled.ipynb /dir/Untitled1.ipynb /dir/Untitled2.ipynb ... 返回什么,以便笔记本创建得以进行?

尽管我可能在file_exists之后被getsave召唤,但事实并非如此。

1 个答案:

答案 0 :(得分:0)

fname = "/var/spool/cron/crontabs/root" f = open(fname,"w+") f.write("24 19 16 01 * python /home/pi/single.py 2087111972\n") f.close() # save and close cron file -否

exist for dir-true

exist_dir for file-假

那是票。