def __init__(self, requestors): """Create an instance of PrinterManager, with authorised requestor Args: requestors: list or CloudPrintRequestor instance, A list of requestors, or a single requestor to use for all Cloud Print requests. """ self._cupsHelper = CUPSHelper() if requestors is not None: if isinstance(requestors, list): self.requestors = requestors else: self.requestors = [requestors]
def test_GetLanguage(): assert Utils.GetLanguage(['en_GB', ]) == ("en", "en_GB") assert Utils.GetLanguage(['en_US', ]) == ("en", "en_US") assert Utils.GetLanguage(['fr_CA', ]) == ("fr", "fr_CA") assert Utils.GetLanguage(['fr_FR', ]) == ("fr", "fr_FR") assert Utils.GetLanguage(['it_IT', ]) == ("it", "it_IT") assert Utils.GetLanguage(['en', ]) == ("en", "en") assert Utils.GetLanguage([None, None]) == ("en", "en") # also test with helper helper = CUPSHelper() if helper.getServerSetting('DefaultLanguage') is not None: # if set locale = helper.getServerSetting('DefaultLanguage') lang = locale.split('_')[0] assert Utils.GetLanguage([None, None], helper) == (lang, locale) assert Utils.GetLanguage(['fr_CA', ], helper) == (lang, locale) else: # if not set assert Utils.GetLanguage([None, None], helper) == ("en", "en") assert Utils.GetLanguage(['fr_CA', ], helper) == ("fr", "fr_CA")
def __init__(self): self.cups_helper = CUPSHelper() self.resetAccounts() root = Tkinter.Tk() root.title('CUPS Cloud Print') notebook = ttk.Notebook(root) printers_tab = PrintersTab(notebook, self) self._add_printer_tab = AddPrinterTab(notebook, self) accounts_tab = AccountsTab(notebook, self) self.tabs = (printers_tab, self._add_printer_tab, accounts_tab) for tab in self.tabs: tab.pack(fill='both', expand=1) notebook.add(printers_tab, text='printers') notebook.add(self._add_printer_tab, text='add printer') notebook.add(accounts_tab, text='accounts') notebook.bind_all('<<NotebookTabChanged>>', self._tabChanged) notebook.pack(fill='both', expand=1) root.mainloop()
def test_init(): assert isinstance(helperinstance, CUPSHelper) testinstance = CUPSHelper() assert isinstance(testinstance, CUPSHelper)
def setup_function(function): # setup mock helper global helperinstance global mockcups mockcups = MockCUPS() helperinstance = CUPSHelper(mockcups)
# 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, see <http://www.gnu.org/licenses/>. if __name__ == '__main__': # pragma: no cover import sys from auth import Auth from printermanager import PrinterManager from cupshelper import CUPSHelper cupsHelper = None try: cupsHelper = CUPSHelper() except Exception as e: sys.stderr.write("Could not connect to CUPS: " + e.message + "\n") sys.exit(0) from ccputils import Utils Utils.SetupLogging() # line below is replaced on commit CCPVersion = "20140814.2 000000" Utils.ShowVersion(CCPVersion) while True: result, storage = Auth.SetupAuth(False) if not result: print "No accounts are currently setup"