def test_stale_cache_new_package(self): with fresh_cache(): self.example_check() # caches the older latest version with self.assertRaises(ValueError): check_outdated(self.package, '5.0') # Suppose that a new version comes out and has just been installed: # the cache must be refreshed with mock(utils.get_url, constantly('{"info": {"version": "5.0"}}')): self.assertEqual(check_outdated(self.package, '5.0'), (False, '5.0'))
def test_basic(self): with disable_cache(): self.example_check() self.assertEqual(check_outdated(self.package, '1.0'), (True, self.version)) self.assertEqual(check_outdated(self.package, self.version), (False, self.version)) self.assertEqual(check_outdated(self.package, self.version + '.0'), (False, self.version))
def getPackageState(cls, packageName, version): """ Check if a package needs to be updated or not args: packageName: the package name version: version of the installed package return: (True, version) if the the package needs to be updated, otherwise (False, version) """ # Ignore autocheck of outdated package that happens at import time os.environ["OUTDATED_IGNORE"] = "1" from outdated import check_outdated from requests.exceptions import ConnectionError try: checkOutdated = check_outdated(packageName, version) except ConnectionError as connError: print("Cannot check update status of %s (%s)" % (packageName, version)) return False, version except ValueError: # We intentionally skip this error # When working in devel mode with an increased version not yet release this Value error # happens: --> example: Version 3.0.2 is greater than the latest version on PyPI: 3.0.1 return False, version except Exception as ex: print(redStr('%s :%s' % (packageName, ex))) return False, version return checkOutdated
def check_update(): current_version = re.search(b'Version: ((\\d\\.)*\\d+)', subprocess.check_output([sys.executable, '-m', 'pip', 'show', 'qrstreamer']))[1].decode('utf-8') is_outdated, latest_version = outdated.check_outdated('qrstreamer', current_version) if is_outdated: print('\n') print('QRStreamer requires an update!\nCurrent version: %s\nLatest Version: %s' % (current_version, latest_version)) print("Upgrade by running \'python -m pip install -U qrstreamer\', or 'pip install -U qrstreamer'")
def run(self): try: stale, latest = check_outdated('mint-amazon-tagger', VERSION) raise DistutilsError('Please update VERSION in __init__. ' 'Current {} PyPI latest {}'.format( VERSION, latest)) except ValueError: pass
def prompt_upgrade(pkg_name, current_version): """ check if current version is out-of-date https://github.com/alexmojaki/outdated copied from https://github.com/WhatsApp/WADebug/blob/958ac37be804cc732ae514d4872b93d19d197a5c/wadebug/cli.py#L40 """ import outdated is_outdated = False try: is_outdated, latest_version = outdated.check_outdated( pkg_name, current_version) except ValueError as error: # catch case of "ValueError: Version 0.10.0 is greater than the latest version on PyPI: 0.9.1" # This would happen on my dev machine if not "is greater than" in str(error): raise # In this case, outdated does not cache the result to disk # so cache it myself (copied from https://github.com/alexmojaki/outdated/blob/565bb3fe1adc30da5e50249912cd2ac494662659/outdated/__init__.py#L61) latest_version = str(error).split(":")[1].strip() import datetime as dt import json with outdated.utils.cache_file(pkg_name, 'w') as f: try: data = [ latest_version, outdated.utils.format_date(dt.datetime.now()) ] json.dump(data, f) except Exception as e: print('Error: ' + str(e)) raise # is_outdated = True # FIXME for debugging if not is_outdated: return is_outdated import click msg_outdated = """The current version of {pkg_name} ({current_version}) is out of date. Run `pip3 install {pkg_name} --upgrade` to upgrade to version {latest_version}, or use `isitfit --skip-check-upgrade ...` to skip checking for version upgrades of isitfit. """ msg_outdated = msg_outdated.format(pkg_name=pkg_name, current_version=current_version, latest_version=latest_version) click.secho(msg_outdated, fg="red") # Give the user some time to read the message and possibly update import time from tqdm import tqdm wait_outdated = 10 click.secho("Will continue in %i seconds" % wait_outdated, fg='yellow') for i in tqdm(range(wait_outdated)): time.sleep(1) return is_outdated
def check(): try: is_outdated, latest = check_outdated('ogb_lite', __version__) if is_outdated: logging.warning("The OGB package is out of date. Your version is " "{}, while the latest version is {}.".format( __version__, latest)) except Exception: pass
def check(): try: is_outdated, latest = check_outdated('ogb', __version__) if is_outdated: logging.warning( f'The OGB package is out of date. Your version is ' f'{__version__}, while the latest version is {latest}.') except Exception: pass
def run_command(): vulners_api = vulners.Vulners(Configuration.vulners_api) # generate current verison of package try: torch_loader = importlib.import_module('pipreqs') except: subprocess.call('pip3 install pipreqs') torch_loader = importlib.import_module('pipreqs') vul_dict = {} if torch_loader: subprocess.call('pipreqs') test = [] count = 0 with open('requirements.txt', 'r') as f: for line in f: test.append(line) array = line.strip().split('==') results = vulners_api.softwareVulnerabilities( array[0].replace('_', '-'), array[1]) # pass in package and verison is_outdated, latest_version = outdated.check_outdated( array[0].replace('_', '-'), array[1]) if results: Message = " " + results['software'][0][ 'description'] + results['software'][0]['title'] if is_outdated: Message += 'Your current version is {0}. Please upgrade to {1}. Changes has been made in requirement file: Changed {2} to {3}'.format( array[1], latest_version, array[1], latest_version) test[count] = array[0] + "==" + latest_version + "\n" info = { 'Message': Message, 'Current_Version': array[1], 'Latest_Version': latest_version } vul_dict[array[0]] = info print(vul_dict) count += 1 # changing old version to new version in requirements.txt with open('requirements.txt', 'w') as f: f.writelines(test) if vul_dict: message = '' for key in vul_dict: message += 'Package:{0}\nCurrent Version:{1}\nLatest Version:{2}\nVulnerability Detected:{3}\n\n'.format( key, vul_dict[key]['Current_Version'], vul_dict[key]['Latest_Version'], vul_dict[key]['Message']) construct_email(message) else: message = 'Good Job! No vulnerability detected.' construct_email(message)
def verify_cli_version(): try: version = pkg_resources.get_distribution(hub.__name__).version is_outdated, latest_version = check_outdated(hub.__name__, version) if is_outdated: print( "\033[93m" + "Hub is out of date. Please upgrade the package by running `pip3 install --upgrade snark`" + "\033[0m") except Exception as e: logger.error(str(e))
def check_latest_version(): # check for newer versions try: is_outdated, latest_version = check_outdated('aws-iam-tester', __version__) if is_outdated: click.echo( f'Your local version ({__version__}) is out of date! Latest is {latest_version}!' ) except ValueError: # this happens when your local version is ahead of the pypi version, # which happens only in development pass
def prompt_upgrade(version): from outdated import check_outdated try: is_outdated, latest_version = check_outdated("wadebug", version) if is_outdated: click.secho( "The current version of wadebug ({}) is out of date. " "Run `pip3 install wadebug --upgrade` " "to upgrade to the latest version ({})\n".format( version, latest_version), fg="yellow", ) except Exception: if Config().development_mode: raise
def update_all_outdated(): versions = [] c = 0 with open('requirements.txt', 'r') as file: for line in file: versions.append(line) a = line.strip().split('==') print(a) is_outdated, latest_version = outdated.check_outdated( a[0].replace('_', '-'), a[1]) if is_outdated: versions[c] = a[0] + '==' + latest_version + '\n' c += 1 print(versions) with open('requirements.txt', 'w') as file: file.writelines(versions)
def run(self): """Run the thread, using `outdated.check_outdated` and checking for errors """ try: outdated, newVersion = check_outdated("physbiblio", __version__) self.result.emit(outdated, newVersion) except ValueError: pBLogger.warning( thestr.outdatedError, exc_info=True, ) except (URLError, ConnectionError): pBLogger.warning( thestr.outdatedWarning, exc_info=True, )
def wrapper(self, *args, **kw): is_outdated = False latest_version = __version__ try: is_outdated, latest_version = check_outdated('tfmake', __version__) except ValueError as e: click.secho(str(e), bold=True) if is_outdated: _msg = 'The package tfmake is out of date. Your version is {}, the latest is {}.'.format( __version__, latest_version) click.secho('\n' + ('* ' * 43), bold=True) click.secho(_msg, bold=True) click.secho('* ' * 43, bold=True) return f(self, *args, **kw)
import os import warnings import sys import shutil import ruamel.yaml as yaml import nltk import outdated from ldt.helpers.exceptions import ResourceError from ldt._version import __version__ warnings.simplefilter('ignore', yaml.error.UnsafeLoaderWarning) try: is_outdated, latest_version = outdated.check_outdated('ldt', __version__) if is_outdated: print( "You are using ldt v." + __version__ + ". Upgrade to v." + latest_version, "with \n pip install --upgrade ldt\nSee what's new: " "https://github.com/annargrs/ldt/blob/master/CHANGES.txt") except ValueError: print("This is LDT", __version__, "- an unpublished development version.") def nltk_download(): """Downloading the necessary NLTK resources if they are missing.""" try: nltk.data.find('tokenizers/punkt') except LookupError:
def run_command(): vulners_api = vulners.Vulners(Configuration.vulners_api) subprocess.call( 'pip freeze --path "C:\\Users\\Henry Boey\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\site-packages" > requirements.txt', shell=True) vul_dict = {} package_dict = {} test = [] with open('requirements.txt', 'r') as f: for line in f: test.append(line) # subprocess.call("pip install {0}".format(line.strip())) array = line.strip().split('==') print(array) results = vulners_api.softwareVulnerabilities( array[0].replace('_', '-'), array[1]) # pass in package and verison is_outdated, latest_version = outdated.check_outdated( array[0].replace('_', '-'), array[1]) if is_outdated: package_dict[array[0]] = { 'Current_Version': array[1], 'Latest_Version': latest_version, 'PackageName': array[0] } print(package_dict) if results: if results.get('software'): Message = " " + results['software'][0][ 'description'] + results['software'][0]['title'] cvss = results['software'][0]['cvss']['score'] cve = results['software'][0]['cvelist'][0] print(Message) elif results.get('NVD'): Message = "" + results['NVD'][0]['description'] cvss = results['NVD'][0]['cvss']['score'] cve = results['NVD'][0]['cvelist'][0] info = { 'Message': Message, 'Current_Version': array[1], 'Latest_Version': latest_version, 'score': cvss, 'cvelist': cve } vul_dict[array[0]] = info print(vul_dict) # changing old version to new version in requirements.txt with open('requirements.txt', 'w') as f: f.writelines(test) if vul_dict: message = '' for key in vul_dict: message += 'Package:{0}\nCurrent Version:{1}\nLatest Version:{2}\nVulnerability Detected:{3}\n\n'.format( key, vul_dict[key]['Current_Version'], vul_dict[key]['Latest_Version'], vul_dict[key]['Message']) message += 'All versions in requirements.txt will be updated automatically to the latest version' if package_dict: for key in package_dict: message += "\n{0} Current Version {1} changed to {2}\n".format( key, package_dict[key]['Current_Version'], package_dict[key]["Latest_Version"]) construct_email(message) else: message = 'Good Job! No vulnerability detected. All versions has been updated to the latest version automatically' construct_email(message) # # update every pcakge and install to latest if package_dict: print('things is not updated to latest') print(package_dict) update_all_outdated() for key in package_dict: subprocess.call( 'pip install --target "C:\\Users\\Henry Boey\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\site-packages" --upgrade {0}' .format(package_dict[key]['PackageName']), shell=True)
def main(): root_logger = logging.getLogger() root_logger.setLevel(logging.INFO) root_logger.addHandler(logging.StreamHandler()) # Disable noisy log spam from filelock from within tldextract. logging.getLogger("filelock").setLevel(logging.WARN) # For helping remote debugging, also log to file. # Developers should be vigilant to NOT log any PII, ever (including being # mindful of what exceptions might be thrown). log_directory = os.path.join(TAGGER_BASE_PATH, 'Tagger Logs') os.makedirs(log_directory, exist_ok=True) log_filename = os.path.join(log_directory, '{}.log'.format( time.strftime("%Y-%m-%d_%H-%M-%S"))) root_logger.addHandler(logging.FileHandler(log_filename)) is_outdated, latest_version = check_outdated('mint-amazon-tagger', VERSION) if is_outdated: print('Please update your version by running:\n' 'pip3 install mint-amazon-tagger --upgrade\n\n') parser = argparse.ArgumentParser( description='Tag Mint transactions based on itemized Amazon history.') define_cli_args(parser) args = parser.parse_args() if args.version: print('mint-amazon-tagger {}\nBy: Jeff Prouty'.format(VERSION)) exit(0) webdriver = None def close_webdriver(): if webdriver: webdriver.close() atexit.register(close_webdriver) def webdriver_factory(): nonlocal webdriver if webdriver: return webdriver webdriver = get_webdriver(args.headless, args.session_path) return webdriver mint_client = MintClient(args, webdriver_factory) # Attempt to fetch the order history if csv files are not already provided. if not has_order_history_csv_files(args): if not maybe_prompt_for_amazon_credentials(args): logger.critical('Failed to get Amazon credentials.') exit(1) if not fetch_order_history( args, webdriver_factory, indeterminate_progress_cli): logger.critical('Failed to fetch Amazon order history.') exit(1) if args.dry_run: logger.info('\nDry Run; no modifications being sent to Mint.\n') def on_critical(msg): logger.critical(msg) exit(1) maybe_prompt_for_mint_credentials(args) results = tagger.create_updates( args, mint_client, on_critical=on_critical, indeterminate_progress_factory=indeterminate_progress_cli, determinate_progress_factory=determinate_progress_cli, counter_progress_factory=counter_progress_cli) if not results.success: logger.critical('Uncaught error from create_updates. Exiting') exit(1) log_amazon_stats(results.items, results.orders, results.refunds) log_processing_stats(results.stats) if args.print_unmatched and results.unmatched_orders: logger.warning( 'The following were not matched to Mint transactions:\n') by_oid = defaultdict(list) for uo in results.unmatched_orders: by_oid[uo.order_id].append(uo) for unmatched_by_oid in by_oid.values(): orders = [o for o in unmatched_by_oid if o.is_debit] refunds = [o for o in unmatched_by_oid if not o.is_debit] if orders: print_unmatched(amazon.Order.merge(orders)) for r in amazon.Refund.merge(refunds): print_unmatched(r) if not results.updates: logger.info( 'All done; no new tags to be updated at this point in time!') exit(0) if args.dry_run: logger.info('Dry run. Following are proposed changes:') if args.skip_dry_print: logger.info('Dry run print results skipped!') else: tagger.print_dry_run(results.updates, ignore_category=args.no_tag_categories) else: num_updates = mint_client.send_updates( results.updates, progress=determinate_progress_cli( 'Updating Mint', max=len(results.updates)), ignore_category=args.no_tag_categories) logger.info('Sent {} updates to Mint'.format(num_updates))
from mintamazontagger import VERSION from outdated import check_outdated if __name__ == '__main__': try: is_stale, latest = check_outdated('mint-amazon-tagger', VERSION) print('Please update VERSION in __init__') exit(1) except ValueError: # If it's already up to date, this will throw exit(0)
def create_gui(self): try: from fbs_runtime.application_context.PyQt5 import ( ApplicationContext) appctxt = ApplicationContext() app = appctxt.app except ImportError: app = QApplication(sys.argv) app.setStyle('Fusion') self.window = QMainWindow() self.quit_shortcuts = [] for seq in ("Ctrl+Q", "Ctrl+C", "Ctrl+W", "ESC"): s = QShortcut(QKeySequence(seq), self.window) s.activated.connect(app.exit) self.quit_shortcuts.append(s) is_outdated, latest_version = check_outdated('mint-amazon-tagger', VERSION) if is_outdated: outdate_msg = QErrorMessage(self.window) outdate_msg.showMessage( 'A new version is available. Please update for the best ' 'experience. https://github.com/jprouty/mint-amazon-tagger') v_layout = QVBoxLayout() h_layout = QHBoxLayout() v_layout.addLayout(h_layout) amazon_group = QGroupBox('Amazon Order History') amazon_group.setMinimumWidth(300) amazon_layout = QVBoxLayout() amazon_mode = QComboBox() amazon_mode.addItem('Fetch Reports') amazon_mode.addItem('Use Local Reports') amazon_mode.setFocusPolicy(Qt.StrongFocus) has_csv = any( [self.args.orders_csv, self.args.items_csv, self.args.refunds_csv]) self.amazon_mode_layout = (self.create_amazon_import_layout() if has_csv else self.create_amazon_fetch_layout()) amazon_mode.setCurrentIndex(1 if has_csv else 0) self.fetch_amazon = not has_csv def on_amazon_mode_changed(i): self.clear_layout(self.amazon_mode_layout) if i == 0: self.amazon_mode_layout = self.create_amazon_fetch_layout() self.fetch_amazon = True elif i == 1: self.amazon_mode_layout = self.create_amazon_import_layout() self.fetch_amazon = False amazon_layout.addLayout(self.amazon_mode_layout) amazon_mode.currentIndexChanged.connect(on_amazon_mode_changed) amazon_layout.addWidget(amazon_mode) amazon_layout.addLayout(self.amazon_mode_layout) amazon_group.setLayout(amazon_layout) h_layout.addWidget(amazon_group) mint_group = QGroupBox('Mint Login && Options') mint_group.setMinimumWidth(350) mint_layout = QFormLayout() mint_layout.addRow( 'Email:', self.create_line_edit('mint_email', tool_tip=NEVER_SAVE_MSG)) mint_layout.addRow( 'Password:'******'mint_password', tool_tip=NEVER_SAVE_MSG, password=True)) mint_layout.addRow( 'MFA Code:', self.create_combobox('mint_mfa_method', ['SMS', 'Email'], lambda x: x.lower())) mint_layout.addRow('Sync first?', self.create_checkbox('mint_wait_for_sync')) mint_layout.addRow('Merchant Filter', self.create_line_edit('mint_input_merchant_filter')) mint_layout.addRow( 'Include MMerchant', self.create_checkbox('mint_input_include_mmerchant')) mint_layout.addRow('Include Merchant', self.create_checkbox('mint_input_include_merchant')) mint_layout.addRow( 'Input Categories Filter', self.create_line_edit('mint_input_categories_filter')) mint_group.setLayout(mint_layout) h_layout.addWidget(mint_group) tagger_group = QGroupBox('Tagger Options') tagger_layout = QHBoxLayout() tagger_left = QFormLayout() tagger_left.addRow('Verbose Itemize', self.create_checkbox('verbose_itemize')) tagger_left.addRow('Do not Itemize', self.create_checkbox('no_itemize')) tagger_left.addRow('Retag Changed', self.create_checkbox('retag_changed')) tagger_right = QFormLayout() tagger_right.addRow('Do not tag categories', self.create_checkbox('no_tag_categories')) tagger_right.addRow('Do not predict categories', self.create_checkbox('do_not_predict_categories')) tagger_right.addRow( 'Max days between payment/shipment', self.create_combobox('max_days_between_payment_and_shipping', ['3', '4', '5', '6', '7', '8', '9', '10'], lambda x: int(x))) tagger_layout.addLayout(tagger_left) tagger_layout.addLayout(tagger_right) tagger_group.setLayout(tagger_layout) v_layout.addWidget(tagger_group) self.start_button = QPushButton('Start Tagging') self.start_button.setAutoDefault(True) self.start_button.clicked.connect(self.on_start_button_clicked) v_layout.addWidget(self.start_button) main_widget = QWidget() main_widget.setLayout(v_layout) self.window.setCentralWidget(main_widget) self.window.show() return app.exec_()
def main(): warn_if_outdated('mint-amazon-tagger', VERSION) is_outdated, latest_version = check_outdated('mint-amazon-tagger', VERSION) if is_outdated: print('Please update your version by running:\n' 'pip3 install mint-amazon-tagger --upgrade') parser = argparse.ArgumentParser( description='Tag Mint transactions based on itemized Amazon history.') define_args(parser) args = parser.parse_args() if args.version: print('mint-amazon-tagger {}\nBy: Jeff Prouty'.format(VERSION)) exit(0) session_path = args.session_path if session_path.lower() == 'none': session_path = None items_csv = args.items_csv orders_csv = args.orders_csv refunds_csv = args.refunds_csv start_date = None if not items_csv or not orders_csv: logger.info('Missing Items/Orders History csv. Attempting to fetch ' 'from Amazon.com.') start_date = args.order_history_start_date duration = datetime.timedelta(days=args.order_history_num_days) end_date = datetime.date.today() # If a start date is given, adjust the end date based on num_days, # ensuring not to go beyond today. if start_date: start_date = start_date.date() if start_date + duration < end_date: end_date = start_date + duration else: start_date = end_date - duration items_csv, orders_csv, refunds_csv = fetch_order_history( args.report_download_location, start_date, end_date, args.amazon_email, args.amazon_password, session_path, args.headless) if not items_csv or not orders_csv: # Refunds are optional logger.critical('Order history either not provided at command line or ' 'unable to fetch. Exiting.') exit(1) orders = amazon.Order.parse_from_csv(orders_csv, ProgressCounter('Parsing Orders - ')) items = amazon.Item.parse_from_csv(items_csv, ProgressCounter('Parsing Items - ')) refunds = ([] if not refunds_csv else amazon.Refund.parse_from_csv( refunds_csv, ProgressCounter('Parsing Refunds - '))) if args.dry_run: logger.info('\nDry Run; no modifications being sent to Mint.\n') # Initialize the stats. Explicitly initialize stats that might not be # accumulated (conditionals). stats = Counter( adjust_itemized_tax=0, already_up_to_date=0, misc_charge=0, new_tag=0, no_retag=0, retag=0, user_skipped_retag=0, personal_cat=0, ) mint_client = MintClient(args.mint_email, args.mint_password, session_path, args.headless, args.mint_mfa_method, args.wait_for_sync) if args.pickled_epoch: mint_trans, mint_category_name_to_id = ( get_trans_and_categories_from_pickle(args.pickled_epoch, args.mint_pickle_location)) else: # Get the date of the oldest Amazon order. if not start_date: start_date = min([o.order_date for o in orders]) if refunds: start_date = min(start_date, min([o.order_date for o in refunds])) # Double the length of transaction history to help aid in # personalized category tagging overrides. today = datetime.date.today() start_date = today - (today - start_date) * 2 mint_category_name_to_id = mint_client.get_categories() mint_transactions_json = mint_client.get_transactions(start_date) epoch = int(time.time()) mint_trans = mint.Transaction.parse_from_json(mint_transactions_json) dump_trans_and_categories(mint_trans, mint_category_name_to_id, epoch, args.mint_pickle_location) updates, unmatched_orders = tagger.get_mint_updates( orders, items, refunds, mint_trans, args, stats, mint_category_name_to_id) log_amazon_stats(items, orders, refunds) log_processing_stats(stats) if args.print_unmatched and unmatched_orders: logger.warning( 'The following were not matched to Mint transactions:\n') by_oid = defaultdict(list) for uo in unmatched_orders: by_oid[uo.order_id].append(uo) for unmatched_by_oid in by_oid.values(): orders = [o for o in unmatched_by_oid if o.is_debit] refunds = [o for o in unmatched_by_oid if not o.is_debit] if orders: print_unmatched(amazon.Order.merge(orders)) for r in amazon.Refund.merge(refunds): print_unmatched(r) if not updates: logger.info( 'All done; no new tags to be updated at this point in time!') exit(0) if args.dry_run: logger.info('Dry run. Following are proposed changes:') if args.skip_dry_print: logger.info('Dry run print results skipped!') else: tagger.print_dry_run(updates, ignore_category=args.no_tag_categories) else: mint_client.send_updates(updates, ignore_category=args.no_tag_categories)
def example_check(self): self.assertEqual(check_outdated(self.package, '0.1'), (True, self.version))
def main(): root_logger = logging.getLogger() root_logger.addHandler(logging.StreamHandler()) # For helping remote debugging, also log to file. # Developers should be vigilant to NOT log any PII, ever (including being # mindful of what exceptions might be thrown). log_directory = os.path.join(TAGGER_BASE_PATH, 'Tagger Logs') os.makedirs(log_directory, exist_ok=True) log_filename = os.path.join( log_directory, '{}.log'.format(time.strftime("%Y-%m-%d_%H-%M-%S"))) root_logger.addHandler(logging.FileHandler(log_filename)) is_outdated, latest_version = check_outdated('mint-amazon-tagger', VERSION) if is_outdated: print('Please update your version by running:\n' 'pip3 install mint-amazon-tagger --upgrade\n\n') parser = argparse.ArgumentParser( description='Tag Mint transactions based on itemized Amazon history.') define_cli_args(parser) args = parser.parse_args() if args.version: print('mint-amazon-tagger {}\nBy: Jeff Prouty'.format(VERSION)) exit(0) mint_client = MintClient(email=args.mint_email, password=args.mint_password, session_path=args.session_path, headless=args.headless, mfa_method=args.mint_mfa_method, wait_for_sync=args.mint_wait_for_sync, progress_factory=indeterminate_progress_cli) if args.dry_run: logger.info('\nDry Run; no modifications being sent to Mint.\n') def on_critical(msg): logger.critical(msg) exit(1) results = tagger.create_updates( args, mint_client, on_critical=on_critical, indeterminate_progress_factory=indeterminate_progress_cli, determinate_progress_factory=determinate_progress_cli, counter_progress_factory=counter_progress_cli) if not results.success: logger.critical('Uncaught error from create_updates. Exiting') exit(1) log_amazon_stats(results.items, results.orders, results.refunds) log_processing_stats(results.stats) if args.print_unmatched and results.unmatched_orders: logger.warning( 'The following were not matched to Mint transactions:\n') by_oid = defaultdict(list) for uo in results.unmatched_orders: by_oid[uo.order_id].append(uo) for unmatched_by_oid in by_oid.values(): orders = [o for o in unmatched_by_oid if o.is_debit] refunds = [o for o in unmatched_by_oid if not o.is_debit] if orders: print_unmatched(amazon.Order.merge(orders)) for r in amazon.Refund.merge(refunds): print_unmatched(r) if not results.updates: logger.info( 'All done; no new tags to be updated at this point in time!') exit(0) if args.dry_run: logger.info('Dry run. Following are proposed changes:') if args.skip_dry_print: logger.info('Dry run print results skipped!') else: tagger.print_dry_run(results.updates, ignore_category=args.no_tag_categories) else: num_updates = mint_client.send_updates( results.updates, progress=determinate_progress_cli('Updating Mint', max=len(results.updates)), ignore_category=args.no_tag_categories) logger.info('Sent {} updates to Mint'.format(num_updates))
import re from outdated import check_outdated with open("../../kikuchipy/release.py") as fid: for line in fid: if line.startswith("version"): branch_version = line.strip().split(" = ")[-1][1:-1] # Within a try/except because we don't want to throw the error if a new # tagged release draft is to be made, we just want to know if the branch # version is different (hopefully always newer if different) from the # PyPI version try: make_release, pypi_version = check_outdated("kikuchipy", branch_version) except ValueError as e: pypi_version = re.findall(r"\s([\d.]+)", e.args[0])[1] make_release = True if make_release: with open("../../doc/changelog.rst", mode="r") as f: content = f.readlines() changelog_start = 0 changelog_end = 0 for i, line in enumerate(content): if line.startswith(branch_version): changelog_start = i + 3 elif line.startswith(pypi_version): changelog_end = i - 1 with open("release_part_in_changelog.rst", mode="w") as f:
with open('requirements.txt', 'r') as file: for line in file: versions.append(line) a = line.strip().split('==') print(a) is_outdated, latest_version = outdated.check_outdated( a[0].replace('_', '-'), a[1]) if is_outdated: versions[c] = a[0] + '==' + latest_version + '\n' c += 1 print(versions) with open('requirements.txt', 'w') as file: file.writelines(versions) def is_admin(): try: return ctypes.windll.shell32.isUserAnAdmin() except: return False if __name__ == "__main__": # run_command() # subprocess.call('pip freeze --path "C:\\Users\\Henry Boey\\AppData\\Local\\Programs\\Python\\Python37-32\\Lib\\site-packages" > requirements.txt',shell=True) #subprocess.call('pip list --outdated --path "C:\Users\Henry Boey\AppData\Local\Programs\Python\Python37-32\Lib\site-packages"') is_outdated, latest = outdated.check_outdated('botocore', '1.19.47') print(is_outdated, latest) # run_command()