コード例 #1
0
ファイル: anaconda_ctl.py プロジェクト: witchel/katana
def remove_old_func(args, api: Binstar):
    args.package = args.package or DEFAULT_PACKAGES
    for package_name in set(args.package):
        package = api.package("KatanaGraph", package_name)

        latest_versions = package["versions"][-args.recent :]
        files = package["files"]
        for f in files:
            basename = f["basename"]
            labels = {l.lower() for l in f["labels"]}
            version = f["version"]
            ndownloads = f["ndownloads"]
            if version in latest_versions:
                # Skip the most recent versions always.
                continue
            if args.label.lower() not in labels:
                # Skip if it doesn't have the label we want
                continue
            if args.keep.lower() in labels:
                # Skip if it has the keep label
                continue
            if args.downloads is not None and ndownloads > args.downloads:
                # Skip if it has been downloaded enough
                continue
            info_str = f"{basename} (labels: {labels}, ndownloads: {ndownloads})"
            if args.really:
                print(f"Deleting {info_str}")
                api.remove_dist("KatanaGraph", package_name, version, basename=basename)
            else:
                print(f"Would delete {info_str}")
コード例 #2
0
    def test_packages_array_param(self, urls):
        api = Binstar()
        urls.register(method='GET', path='/packages/u1?package_type=conda&package_type=pypi', content='[]')

        packages = api.user_packages('u1', package_type=['conda', 'pypi'])

        urls.assertAllCalled()
コード例 #3
0
    def test_packages_parameters(self, urls):
        api = Binstar()
        urls.register(method='GET', path='/packages/u1?platform=osx-64&package_type=conda&type=app', content='[]')

        packages = api.user_packages('u1', platform='osx-64', type_='app', package_type='conda')

        urls.assertAllCalled()
コード例 #4
0
    def test_packages_empty(self, urls):
        api = Binstar()
        urls.register(method='GET', path='/packages/u1', content='[]')

        packages = api.user_packages('u1')

        self.assertEqual(packages, [])
        urls.assertAllCalled()
コード例 #5
0
    def test_packages_empty(self, urls):
        api = Binstar()
        urls.register(method='GET', path='/packages/u1', content='[]')

        packages = api.user_packages('u1')

        self.assertEqual(packages, [])
        urls.assertAllCalled()
コード例 #6
0
ファイル: logout.py プロジェクト: Zulko/binstar_client
def main(args):
    
    config = get_config()
    kr = get_keyring()
    token = kr.get_password('binstar-token', getpass.getuser())
    url = config.get('url', 'https://api.binstar.org')
    bs = Binstar(token, domain=url)
    bs.remove_authentication(token)
    kr.delete_password('binstar-token', getpass.getuser())
コード例 #7
0
    def test_packages_array_param(self, urls):
        api = Binstar()
        urls.register(method='GET',
                      path='/packages/u1?package_type=conda&package_type=pypi',
                      content='[]')

        packages = api.user_packages('u1', package_type=['conda', 'pypi'])

        urls.assertAllCalled()
コード例 #8
0
    def test_packages_parameters(self, urls):
        api = Binstar()
        urls.register(
            method='GET',
            path='/packages/u1?platform=osx-64&package_type=conda&type=app',
            content='[]')

        packages = api.user_packages('u1',
                                     platform='osx-64',
                                     type_='app',
                                     package_type='conda')

        urls.assertAllCalled()
コード例 #9
0
ファイル: login.py プロジェクト: bkreider/binstar_client
def main(args):
    
    config = get_config()
    kr = get_keyring()
    token = kr.get_password('binstar-token', getpass.getuser())
    url = config.get('url', 'https://api.binstar.org')
    bs = Binstar(token, domain=url,)
    
    username = raw_input('Username: '******'Binstar-Cli', url, ['packages'])
    kr.set_password('binstar-token', getpass.getuser(), token)
    print 'login successful'
コード例 #10
0
def get_binstar(args=None):
    from binstar_client import Binstar

    if args and args.token:
        token = args.token
    else:
        config = get_config()
        if config.get('keyring'):
            if config['keyring'] == 'plain-text':
                set_keyring(PlaintextKeyring())

        kr = get_keyring()
        token = kr.get_password('binstar-token', getpass.getuser())

    url = get_config().get('url', 'https://api.binstar.org')

    return Binstar(
        token,
        domain=url,
    )
コード例 #11
0
ファイル: gui.py プロジェクト: tlambert03/MOSAICpy
def main():
    # create the APP instance
    APP = QtWidgets.QApplication(sys.argv)
    appicon = QtGui.QIcon(util.getAbsoluteResourcePath("gui/logo_dark.png"))
    APP.setWindowIcon(appicon)

    # register icon with windows
    if sys.platform.startswith("win32"):
        import ctypes

        myappid = "mosaicpy.MOSAICpy." + __version__
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

    # set up the logfile
    fh = qtlogger.LogFileHandler(maxBytes=100000, backupCount=2)
    logger.addHandler(fh)
    fh.setLevel(logging.DEBUG)
    logger.info(">" * 10 + "  MOSAICpy STARTUP  " + "<" * 10)
    # instantiate the main window widget
    mainGUI = mainwindow.main_GUI()
    mainGUI.setWindowIcon(appicon)

    # instantiate the execption handler
    exceptionHandler = exceptions.ExceptionHandler()
    sys.excepthook = exceptionHandler.handler
    exceptionHandler.errorMessage.connect(mainGUI.show_error_window)

    # try to import slmgen and add to tools menu
    try:
        from slmgen import SLMdialog

        mainGUI.slmDialog = SLMdialog(mainGUI)
        mainGUI.actionSLMwindow = QtWidgets.QAction(mainGUI)
        mainGUI.actionSLMwindow.setObjectName("actionSLMwindow")
        mainGUI.menuTools.addAction(mainGUI.actionSLMwindow)
        mainGUI.actionSLMwindow.setText("SLM Pattern Generator")
        mainGUI.actionSLMwindow.triggered.connect(mainGUI.slmDialog.show)
    except ImportError:
        logger.error(
            "Could not import slmgen. Cannot add SLM Generator to Tools menu.")

    # request permission to send error reports
    if not SETTINGS.value("error_permission_requested", False):
        box = QtWidgets.QMessageBox()
        box.setWindowTitle("Help improve MOSAICpy")
        box.setText("Thanks for using MOSAICpy.\n\nIn order to improve the "
                    "stability of MOSAICpy, we'd like to send automatic "
                    "error and crash logs.\n\nNo personal "
                    "information is included and the full error-reporting "
                    "code can be viewed in mosaicpy.gui.exceptions. "
                    "Thanks for your help!\n")
        box.setIcon(QtWidgets.QMessageBox.Question)
        box.addButton(QtWidgets.QMessageBox.Ok)
        box.setDefaultButton(QtWidgets.QMessageBox.Ok)
        pref = QtWidgets.QCheckBox("Send anonymous error logs")
        box.setCheckBox(pref)

        def setOptOut(value):
            SETTINGS.value(settings.ALLOW_BUGREPORT.key,
                           True if value else False)

        pref.stateChanged.connect(setOptOut)
        box.exec_()
        SETTINGS.setValue("error_permission_requested", True)

    # if we crashed last time, send a bug report (if allowed)
    if SETTINGS.value("cleanExit", False) and SETTINGS.value(
            settings.ALLOW_BUGREPORT.key, True):
        logger.warning(
            "MOSAICpy failed to exit cleanly on the previous session")
        try:
            with open(qtlogger.LOGPATH, "r") as f:
                crashlog = f.read()
                exceptions.client.captureMessage("MOSAICpyGUI Bad Exit\n\n" +
                                                 crashlog)
        except Exception:
            pass

    # check for updates
    if SETTINGS.value(settings.CHECK_UPDATES.key, True):
        try:
            from binstar_client import Binstar

            client = Binstar()
            llsinfo = client.package("talley", "mosaicpy")
            newestVersion = llsinfo["latest_version"]
            if StrictVersion(newestVersion) > StrictVersion(__version__):
                dialogs.NewVersionDialog(newestVersion).exec_()
        except Exception as e:
            logger.error("Could not check for updates: {}".format(e))

    # check to see if the cudaDeconv binary is valid, and alert if not
    try:
        from mosaicpy import cudabinwrapper

        binary = cudabinwrapper.get_bundled_binary()
        logger.info(cudabinwrapper.CUDAbin(binary).list_gpus())
        # if not mosaicpy.nGPU() > 0:
        #     QtWidgets.QMessageBox.warning(mainGUI, "No GPUs detected!",
        #         "cudaDeconv found no "
        #         "CUDA-capable GPUs.\n\n Preview/Processing will likely not work.",
        #         QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.NoButton)
    except Exception:
        pass
        # QtWidgets.QMessageBox.warning(
        #     mainGUI, "No binary detected!",
        #     'Unable to detect bundled cudaDeconv binary. We will not be able'
        #     ' to do much without it.\n\n'
        #     'The cudaDeconv.exe program is owned by HHMI Janelia Research Campus, '
        #     'and access to that program can be arranged via a license agreement with them. '
        #     'Please contact [email protected].\n\n'
        #     'More info in the documentation at mosaicpy.readthedocs.io',
        #     QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.NoButton)

    SETTINGS.setValue("cleanExit", False)
    SETTINGS.sync()
    sys.exit(APP.exec_())
コード例 #12
0
 def test_licenses_array_param(self, urls):
     api = Binstar()
     urls.register(method='GET', path='/license', content='[]')
     licenses = api.user_licenses()
     urls.assertAllCalled()