Mac OS中SVN工具Versions日期重置脚本

简介: Versions是一个Mac OS下挺棒的SVN工具,不过有日期限制。网上有人提供了将Versions的使用日期重置的脚本,这个脚本有些值得学习的地方。

Versions是一个Mac OS下挺棒的SVN工具,不过有日期限制。网上有人提供了将Versions的使用日期重置的脚本,这个脚本有些值得学习的地方。贴出来做个记录。

 

#!/usr/bin/env python

import os, sys, re, plistlib, subprocess, re, time



userdir = os.path.expanduser('~')
prefdir = os.path.join(userdir, 'Library/Preferences')

pfile_a = os.path.join(prefdir,'com.madebysofa.Versions.plist')
pfile_b = 'com.picodev.Versions.plist'

hfile_a = '.CF89AA64'
hfile_b = '.FB64CF89'

globalprefs = os.path.join(prefdir, '.GlobalPreferences.plist')


def convert_plist_to_xml(plist_path):
	cmdline = '/usr/bin/plutil -convert xml1 "%s"' % plist_path
	os.system(cmdline)

def isVersionsRunning():
	p = subprocess.Popen(['ps','-Ac'],stdout=subprocess.PIPE)
	output = p.stdout.read()
	apps_re = re.search('^([0-9]+).*Versions$', output, re.M)
	if apps_re:
		return int(apps_re.group(1))
	else:
		return False

def killRunningVersions():	
	pid = isVersionsRunning()
	if pid:
		sys.stdout.write('Stopping currently running Versions...\n')
		os.system('kill %d' % pid)
	while isVersionsRunning():
		time.sleep(0.1)
		
def relaunchVersions():
	os.system('open -a /Applications/Versions.app')


if __name__ == '__main__':
	
	killRunningVersions()
	
	pfile_a_path = os.path.join(prefdir, pfile_a)
	pfile_b_path = os.path.join(prefdir, pfile_b)
	
	# --1) Start by deleting the hidden files.
	hfile_a1 = os.path.join(userdir, hfile_a)
	if os.path.exists(hfile_a1):
		print 'Removing "%s"'%hfile_a1
		os.remove(hfile_a1)
		
	hfile_b1 = os.path.join(os.path.join(userdir, 'Library/'), hfile_b)
	if os.path.exists(hfile_b1):
		print 'Removing "%s"'%hfile_b1
		os.remove(hfile_b1)
	
	# -- 2) Now, delete the expiry token from the globalprefs file...
	if os.path.exists(globalprefs):
		convert_plist_to_xml(globalprefs)
		pl = plistlib.readPlist(globalprefs)
		if 'com.madebysofa.Versions.ezsRequiredToken' in pl.keys():
			sys.stdout.write('Removing expiry token from .Globalprefs...\n')
			del pl['com.madebysofa.Versions.ezsRequiredToken']
			plistlib.writePlist(pl, globalprefs)
			
	# -- 2) Make sure that the "FirstRunDate" is also removed...
	if os.path.exists(pfile_a):
		convert_plist_to_xml(pfile_a)
		pl = plistlib.readPlist(pfile_a)
		if 'FirstRunDate' in pl.keys():
			sys.stdout.write('Removing FirstRunDate from "%s"\n' % pfile_a)
			del pl['FirstRunDate']
		if 'EZSBookmarksSelectionMask' in pl.keys():
			sys.stdout.write('Removing EZSBookmarksSelectionMask from "%s"' % pfile_a)
			del pl['EZSBookmarksSelectionMask']
			plistlib.writePlist(pl, pfile_a)
			
			
	sys.stdout.write('Launching Versions....')
	relaunchVersions()
	
	



 

目录
相关文章
|
编解码 Android开发
Android获取设备各项信息(设备id、ip地址、设备名称、运行商、品牌、型号、分辨率、处理器、国家码、系统语言、网络类型、oaid、android版本、操作系统版本、mac地址、应用程序签名..)1
Android获取设备各项信息(设备id、ip地址、设备名称、运行商、品牌、型号、分辨率、处理器、国家码、系统语言、网络类型、oaid、android版本、操作系统版本、mac地址、应用程序签名..)
974 1
|
2月前
|
安全 Linux iOS开发
SonarQube Server 2025 Release 5 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
SonarQube Server 2025 Release 5 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
156 0
SonarQube Server 2025 Release 5 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
|
6月前
|
存储 Unix Shell
确定Shell脚本在操作系统中的具体位置方法。
这对于掌握Linux的文件系统组织结构和路径方面的理解很有帮助,是我们日常工作和学习中都可能使用到的知识。以上讲解详细清晰,应用简便,是每一个想要精通操作系统的计算机爱好者必备的实用技能。
152 17
|
8月前
|
自然语言处理 数据库 iOS开发
DBeaver Ultimate Edtion 25.0 Multilingual (macOS, Linux, Windows) - 通用数据库工具
DBeaver Ultimate Edtion 25.0 Multilingual (macOS, Linux, Windows) - 通用数据库工具
553 12
DBeaver Ultimate Edtion 25.0 Multilingual (macOS, Linux, Windows) - 通用数据库工具
|
iOS开发 MacOS
MAC OS更新系统后IDEA中的SVN报错无法使用
MAC OS更新系统后IDEA中的SVN报错无法使用
|
编解码 开发工具 Android开发
Android获取设备各项信息(设备id、ip地址、设备名称、运行商、品牌、型号、分辨率、处理器、国家码、系统语言、网络类型、oaid、android版本、操作系统版本、mac地址、应用程序签名..)2
Android获取设备各项信息(设备id、ip地址、设备名称、运行商、品牌、型号、分辨率、处理器、国家码、系统语言、网络类型、oaid、android版本、操作系统版本、mac地址、应用程序签名..)2
858 2
|
安全 网络安全 iOS开发
macOS系统安装NMAP扫描工具
macOS系统安装NMAP扫描工具
654 1
|
小程序 开发者
微信开发者工具如何集成SVN、同时解决集成SVN无效果的问题
这篇文章介绍了如何在微信开发者工具中集成SVN版本控制系统,并提供了解决集成后无效果问题的方法。
微信开发者工具如何集成SVN、同时解决集成SVN无效果的问题
|
iOS开发 MacOS
macOS开机自启动执行脚本
【8月更文挑战第23天】在macOS上设置开机自动执行脚本可通过三种方式:一是利用“系统偏好设置”中的“用户与群组”功能直接添加脚本或应用;二是通过创建`.plist`文件并放置于`LaunchAgents`目录,这种方式能更精细地控制脚本运行;三是使用cron任务,在系统启动时执行脚本,但该方法不太适用于图形界面程序且可能受限于启动顺序。每种方法各有优缺点,需根据实际情况选择。
2496 0
|
Linux C语言 iOS开发
MacOS环境-手写操作系统-06-在mac下通过交叉编译:C语言结合汇编
MacOS环境-手写操作系统-06-在mac下通过交叉编译:C语言结合汇编
284 0

热门文章

最新文章

推荐镜像

更多