def start_surface_app(): script1 = """send {Lwin} sleep 500 send surface sleep 500 send {enter} sleep 2000 send #{up}""" script2 = """WinActivate, Surface sleep 750 PixelGetColor, ESurface, 593, 298, RGB ; 0x0E0E0E PixelGetColor, EBar, 57, 631, RGB ; 0xF2F2F2 PixelGetColor, EBlue, 1472, 1504, RGB ; 0x0078D7 send #4 sleep 500 send %ESurface%%EBar%%EBlue%{enter}""" BetaScript(script1) # Launched in Windows store checks while True: time.sleep(3) if str(BetaScript(script2, True)) == str("0x0E0E0E0xF2F2F20x0078D7"): return True else: p("Waiting 3 seconds...")
def setup_to_internet(): do("control.exe /name Microsoft.NetworkAndSharingCenter", "ignore") time.sleep(.75) script = """WinActivate, Network and Sharing Center sleep, 500 IfWinActive, Network and Sharing Center send, #{up} sleep, 750 click, 690, 380 sleep, 750 send, {down 2}{enter} sleep, 500 send, MSFTOPEN{tab} sleep, 500 send, n sleep, 500 send, {tab}{space}{enter} sleep, 750 send, {tab}{enter} sleep, 500 send, !{f4}""" p("Plug in ethernet cable now if you wish to!") for x in range(3): winsound.Beep(2000, 500) time.sleep(.5) BetaScript(script)
def setup(label, ps): progress(label, "starting setup") try: with open(jar(label), "rb") as brine: ps = pickle.load(brine) except IOError: progress(label, "generating distributions") secret_l2_dist = ps.secret_l2_distribution() progress(label, "done secret l2 dist") query_l2_dist = ps.query_l2_distribution() progress(label, "done query l2 dist") e3_dist = ps.e3_distribution() progress(label, "done e3 dist") one_shot_dist = ps.one_shot_distribution() progress(label, "done one shot dist") f = tail_probability(one_shot_dist, ps.threshold()) p(label, "oneshot", float(-log2(f))) p(label, "max_abs_e3", max(dist_absolute(e3_dist))) with open(jar(label), "wb") as brine: pickle.dump(ps, brine) progress(label, "done setup")
def try_metacommands(self, line): if len(line) == 0: return False if line.strip() == '%': if self.mode != 'speedy': self.mode = 'speedy' else: self.mode = 'normal' self.update_banner() u.gray("metacommand registered") return True # handle metacommands if line[0] == '!': if line.strip() == '!print': u.y('\n'.join(self.code)) if line.strip() == '!debug': self.debug = not self.debug if line.strip() == '!verbose_exc': self.verbose_exceptions = not self.verbose_exceptions if line.strip() == '!reset': self.__init__(None) #if line.strip() == '!cleanup': #clears the /repl-tmpfiles directory #u.clear_repl_tmpfiles() #os.makedirs(os.path.dirname(self.tmpfile)) #if line.strip() == '!which': #print(self.tmpfile) if line.strip() == '!help': u.b('Currently implemented macros listing:') u.p('\n'.join(codegen.macro_argc.keys())) u.gray("metacommand registered") return True return False
def s_09(): pin_items() pin_cortana() BetaScript("send {Lwin}") time.sleep(.9) resize_cio() p("Ran 2 checks 2 operations 5 iterations 0 tests")
def update_surface_app(click): script = """WinActivate, Store sleep 500 PixelGetColor, ESurfaceLogo, 186, 247, RGB ;0x0078D7 PixelGetColor, EBlueBlob, 937, 275, RGB ;0x054ABC PixelGetColor, EInstall, 267, 929, RGB ;0xFFFFFF PixelGetColor, EComments, 943, 1194, RGB ;0xFFFFFF Send, !{tab} sleep, 500 ; 0x00787D70x054ABC0xFFFFFF0xFFFFFF Send, %ESurfaceLogo%%EBlueBlob%%EInstall%%EComments%{enter}""" for x in range(5): time.sleep(3) if str(BetaScript(script, True)) == str("0x0078D70x054ABC0xF0xF"): # BetaScript("WinActivate Store\nsleep 500\nsend {enter}") if click: BetaScript("WinActivate Store\nclick, 267, 929") return True else: p("Trying again in 3 seconds...") else: launch_store() update_surface_app()
def office_login(): do("powershell start microsoft-edge:http://aka.ms/365") script1 = """WinActivate, Sign in to your account PixelGetColor, EOffice, 1894, 283, RGB PixelGetColor, ELock, 358, 125, RGB PixelGetColor, EBar, 1957, 572, RGB send, !{tab} sleep, 500 send, %EOffice%%ELock%%EBar%{enter}""" script2 = """WinActivate, Sign in to your account sleep, 500 Send, {fname}.{lname}@mssummit.net{tab} sleep, 500 Send, P@ssword1 sleep 200 send {tab} sleep 200 send {space} sleep, 500 send {enter}""" while True: time.sleep(5) if str(BetaScript(script1, True)) == str('0xEB3C000x107C100xF'): break else: p("Waiting 5 seconds...") time.sleep(.75) BetaScript(script2.format(fname=usernames()['fname'], lname=usernames()['lname'], tab="{tab}", space="{space}", enter="{enter}")) return True
def test_edge(): script = """WinActivate, Start sleep, 500 send, #1 sleep, 1500 send, ^l sleep, 200 send, ^c sleep, 200 send !{f4} sleep, 500 send, ^v{enter}""" skip = True while True: BetaScript(script) # NEVER sleep after running tests. if skip: test_result = "Norton Pengra is cool" skip = False else: test_result = input("/!\: ") p("Processing data...") if test_result != "http://aka.ms/cioS16": p("Error Code: MA2") else: break return True
def do(label, lgsq, lgeq): with open(jar(label), "rb") as brine: ps = pickle.load(brine) progress(label, "starting s/{}/e/{}".format(lgsq, lgeq)) f = tail_probability(ps.one_shot_s_quantile(lgsq), ps.threshold()) p(label, "s/{}/e/{}/cost".format(lgsq, lgeq), float(-log2(f))) progress(label, "done s/{}/e/{}".format(lgsq, lgeq))
def s_05(): # Don't call any other functions, it's called in the function below # I'm just a f*****g moron and coded it like a piece of shit score = install_office() # 1 test 1 operation for x in range(2): BetaScript("send {LWin}") time.sleep(.2) BetaScript("send {Lwin}") p("Ran 3 operations 3 tests {}% pass".format((score / 1) * 100))
def test_internet(): while True: try: import urllib.request test = urllib.request.urlopen("http://www.google.com", timeout=3).read() return True except: p("Still no internet! Will try again in 3 seconds...") time.sleep(3)
def s_05(): # Don't call any other functions, it's called in the function below # I'm just a f*****g moron and coded it like a piece of shit score = install_office() # 1 test 1 operation for x in range(2): BetaScript("send {LWin}") time.sleep(.2) BetaScript("send {Lwin}") p("Ran 3 operations 3 tests {}% pass".format((score/1)*100))
def test_os_version(): p("Determining if you have the right build version...") is_right_build = subprocess.check_output('powershell [environment]::OSVersion.Version.Major -eq 10 -and [environment]::OSVersion.Version.Build -eq 10586', shell=True).strip().decode() if is_right_build != "True": p("You have the wrong build of Windows! (Not 10586)") p('Warning Code: S1W') p("Hit [Enter] to continue anyways...") p('OR') i("Hit [CTRL + C] to stop Snowman and reset the OS") return True
def accept_onenote_terms(): full = "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\ONENOTE.EXE" BetaScript(""" send {LWin} sleep 900 send onenote 2016 sleep 500 send {enter} """) p("Don't touch anything!") time.sleep(4.5) kill()
def s_06(): change_weather() # 1 operation launch_store() # 2 checks 1 operation update_surface_app(False) # 1 test 2 operations p("USER CHECK:") p("IF THE BUTTON SAYS \"UPDATE\" THEN CLICK ON IT AND THEN CLOSE THE STORE ONCE UPDATE COMPLETED. DO NOT INSTALL OTHER UPDATES.") p("IF THE BUTTON SAYS \"OPEN\" CLOSE THE STORE WITHOUT UPDATING OR OPENING ANYTHING.") p("WHEN COMPLETE, PUSH {ENTER}") input("...") # start_surface_app() # 1 operation 1 test # update_surface_app(False) # 1 test 2 operations (Run a second time because need to test to see if surface app is ready) # set_pen_settings() # 1 operation p("Ran 2 checks 8 operations 3 tests")
def test_tile_positions(): p("Determining Tile positions...") snowman = """Send {LWin} Sleep 750 PixelGetColor, ECalendar, 550, 133, RGB PixelGetColor, EPhotos, 886, 357, RGB PixelGetColor, ENews, 1732, 595, RGB PixelGetColor, EOnenote, 1538, 795, RGB PixelGetColor, ESurface, 832, 1084, RGB PixelGetColor, EPaint, 1347, 1069, RGB send, !{tab} sleep, 750 send, %ECalendar%%Ephotos%%ENews%%EOnenote%%ESurface%%EPaint%{enter}""" if not str(BetaScript(snowman, True)) == str("0x0078D70x0078D70xD134380x80397B0x0078D70xFCD116"): p("Tiles incorrectly configured!") return False return True
def generate_kuseni(nickname=''): if has_any_word(nickname, (u'だって終わらない', u'どこまでも自転車で行く')): return u'%sくせに…' % nickname if p(15): return u'%sが未だにbotなのか人力なのか分からない…' % nickname elif p(15): if nickname[-2:] == u'さん': nickname = nickname[:-2] return u'「%sさんっていつもふざけてるよね」「いい意味で」' % nickname elif p(15): return u'「%sにゃん?あああの妖怪なんとかの」' % nickname elif p(15): return u'%sはキメ顔でそう言った。' % nickname else: return u'%sのくせに…' % nickname
def setup(label, ps): progress(label, "starting setup") try: with open(jar(label), "rb") as brine: ps = pickle.load(brine) except IOError: progress(label, "generating distributions") secret_l2_dist = ps.secret_l2_distribution() query_l2_dist = ps.query_l2_distribution() one_shot_dist = ps.one_shot_distribution() f = tail_probability(one_shot_dist, ps.threshold()) p(label, "oneshot", float(-log2(f))) with open(jar(label), "wb") as brine: pickle.dump(ps, brine)
def generate_aizuchi(worse=False): candidates = [ u'ガタッ', u'ですよねー', u'なるほどやでー', u'ふむふむ', u'へぇー', u'φ(`д´)メモメモ...', u'ふーん', u'ほほー', u'><', ] #, 'にゃんぱすー'] if worse: # (ゝω・)vキャピッ # 'エイプリルフールおつ', candidates += [ u'すみません', u'草不可避', u'うにー', u'(∩゚д゚)アーアーきこえなーい', u'うわ' + (u'あ' * random.randint(0,3)), u'ぷんぷくり~ん(怒) http://bit.ly/qq66qg ', u'激おこぷんぷん丸', u'激おこスティックファイナリアリティぷんぷんドリーム', u'エターナルフォースブリザード', u'えー! なにそれ!? 知りたい知りたーい♪', u'私、気になります!', u'それすごいいいね!', u'\(^o^)/', u'てへぺろ(・ω<)', u'あげぽよ', u'♡', u'\どんまい/', u'kokomadeやで', u'シャバドゥビタッチヘーンシーン!!', u'ティウン' * random.randint(2, 5), ] if p(50): candidates.append(u'うそおつ') # if (p(50)) $choix[] = 'エイプリルフールおつ'; if p(30): candidates.append(u'm9(^Д^)プギャー') return my_choose(candidates, use_gaussian=False)
def s_08(): if input("Do you want to clear tiles? If no, will start pinning operation. (y/N)").lower().startswith("y"): clear_tiles() # 1 operation time.sleep(.2) input("press {enter} when startmenu (AND TASKBAR DOES NOT CONTAIN ANY APPS EXCEPT FOR EDGE, EXPLORER AND STORE) is empty") add_first_block() time.sleep(.2) add_second_block() time.sleep(.2) add_third_block() time.sleep(.2) add_fourth_block() time.sleep(.2) add_fifth_block() time.sleep(.2) add_sixth_block() p("Ran 0 checks 1 operation @ 27 iterations 0 tests")
def install_office(): office_login() f = download_office_exe() do(f) while True: p("Checking to see if build completed...") time.sleep(3), check = os.path.exists( "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16") check = check and os.path.isfile( "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\excel.exe" ) check = check and os.path.isfile( "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\lync.exe" ) check = check and os.path.isfile( "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\msaccess.exe" ) check = check and os.path.isfile( "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\mspub.exe" ) check = check and os.path.isfile( "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\onenote.exe" ) check = check and os.path.isfile( "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\outlook.exe" ) check = check and os.path.isfile( "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\powerpnt.exe" ) check = check and os.path.isfile( "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\winword.exe" ) if check: time.sleep(5) kill("OfficeC2RClient.exe", True) return True else: p("Error Code: MA_365II")
def s_08(): if input( "Do you want to clear tiles? If no, will start pinning operation. (y/N)" ).lower().startswith("y"): clear_tiles() # 1 operation time.sleep(.2) input( "press {enter} when startmenu (AND TASKBAR DOES NOT CONTAIN ANY APPS EXCEPT FOR EDGE, EXPLORER AND STORE) is empty" ) add_first_block() time.sleep(.2) add_second_block() time.sleep(.2) add_third_block() time.sleep(.2) add_fourth_block() time.sleep(.2) add_fifth_block() time.sleep(.2) add_sixth_block() p("Ran 0 checks 1 operation @ 27 iterations 0 tests")
def test_internet_connection(): while True: p("Making sure you're not connected to the internet...") good_internet = True try: subprocess.check_output('ping www.google.com') except subprocess.CalledProcessError: good_internet = False break if good_internet: p("Please disconnect from the internet!") p("Error Code S2W") p("Testing again in 5 seconds...") time.sleep(5) return True
def office_login(): do("powershell start microsoft-edge:http://aka.ms/365") script1 = """WinActivate, Sign in to your account PixelGetColor, EOffice, 1894, 283, RGB PixelGetColor, ELock, 358, 125, RGB PixelGetColor, EBar, 1957, 572, RGB send, !{tab} sleep, 500 send, %EOffice%%ELock%%EBar%{enter}""" script2 = """WinActivate, Sign in to your account sleep, 500 Send, {fname}.{lname}@mssummit.net{tab} sleep, 500 Send, P@ssword1 sleep 200 send {tab} sleep 200 send {space} sleep, 500 send {enter}""" while True: time.sleep(5) if str(BetaScript(script1, True)) == str('0xEB3C000x107C100xF'): break else: p("Waiting 5 seconds...") time.sleep(.75) BetaScript( script2.format(fname=usernames()['fname'], lname=usernames()['lname'], tab="{tab}", space="{space}", enter="{enter}")) return True
def _selectPrefPane(title): t = _prefTitleRegion() i = t.left(1).right(50) i.click() util.select_all() util.delete_text() type(title[0]) type(title[1]) # Not needed wait(0.5) type(Key.DOWN) wait(0.5) type(Key.DOWN) wait(0.5) t.wait(p(title))
def install_office(): office_login() f = download_office_exe() do(f) while True: p("Checking to see if build completed...") time.sleep(3), check = os.path.exists("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16") check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\excel.exe") check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\lync.exe") check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\msaccess.exe") check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\mspub.exe") check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\onenote.exe") check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\outlook.exe") check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\powerpnt.exe") check = check and os.path.isfile("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\winword.exe") if check: time.sleep(5) kill("OfficeC2RClient.exe", True) return True else: p("Error Code: MA_365II")
def update_hw_config_force(hardware_cfg: Path) -> None: """Generate and replace the hardware configuration. Performs no safety checks, but doesn't write if ``DRY_RUN`` is true. :param hardware_cfg: Path to ``hosts/$(hostname)-hardware-configuration.nix`` file to replace. """ info(("Updating " if hardware_cfg.exists() else "Generating ") + p(hardware_cfg)) cmd(f"nixos-generate-config --show-hardware-config > {hardware_cfg}") new_hardware_config = get_output( ["nixos-generate-config", "--show-hardware-config"] ) if not DRY_RUN: hardware_cfg.write_text(new_hardware_config)
def testPrefPaneNav(): "Test arrow-key navigaiton of preference panes." util.open_preferences() t=_prefTitleRegion() firstPrefPane(t, p("EditorPaneTitle.png")) nextPrefPane(t, p("FontsPaneTitle.png")) nextPrefPane(t, p("HintsPaneTitle.png")) nextPrefPane(t, p("KeyBindingsPaneTitle.png")) nextPrefPane(t, p("RunandDebugPaneTitle.png")) nextPrefPane(t, p("UpdatePaneTitle.png")) nextPrefPane(t, p("VisualThemePaneTitle.png")) wait(2) util.dismiss_dialog()
def testPrefPaneNav(): "Test arrow-key navigaiton of preference panes." util.open_preferences() t = _prefTitleRegion() firstPrefPane(t, p("EditorPaneTitle.png")) nextPrefPane(t, p("FontsPaneTitle.png")) nextPrefPane(t, p("HintsPaneTitle.png")) nextPrefPane(t, p("KeyBindingsPaneTitle.png")) nextPrefPane(t, p("RunandDebugPaneTitle.png")) nextPrefPane(t, p("UpdatePaneTitle.png")) nextPrefPane(t, p("VisualThemePaneTitle.png")) wait(2) util.dismiss_dialog()
def update_hw_config(args: Args, repo_root: Path, hardware_cfg: Path) -> None: """Update ``hardware_cfg``, checking that it's not modified in the repo.""" dbg("Getting `git status` to check if hardware config has been modified.") git_status = get_output( ["git", "status", "--porcelain", "--untracked-files"], cwd=repo_root, ).splitlines() # Determine if the local hardware configuration is modified by seeing if # any of the modified filenames match it. hardware_cfg_modified = any( # Slice the string to transform # " M hosts/dahurica-hardware-configuration.nix" # ^^^^ # 0123 # into # "hosts/dahurica-hardware-configuration.nix" hardware_cfg.samefile(repo_root / filename[3:]) for filename in git_status if GIT_STATUS_MODIFIED.match(filename) ) dbg( "Hardware configuration " + ("has" if hardware_cfg_modified else f"has {BOLD}not{RESET_BOLD}") + " been modified." ) if hardware_cfg_modified: if args.force: error(f"There are uncomitted changes to {p(hardware_cfg)};") error("refusing to overwrite with `nixos-generate-config`.") error("Either commit your changes or pass --force to overwrite local files") args.update = False else: info( f"There are uncomitted changes to {p(hardware_cfg)} but " + p("--force") + " was given; overwriting" ) # We may have updated `args.update` above, so double-check it here. if args.update: # Note: `DRY_RUN` is handled in `update_hw_config_force`. update_hw_config_force(hardware_cfg)
from util import do, p, BetaScript, kill, usernames import subprocess, time, os, os.path p("Importing s_06!") def s_06(): change_weather() # 1 operation launch_store() # 2 checks 1 operation update_surface_app(False) # 1 test 2 operations p("USER CHECK:") p("IF THE BUTTON SAYS \"UPDATE\" THEN CLICK ON IT AND THEN CLOSE THE STORE ONCE UPDATE COMPLETED. DO NOT INSTALL OTHER UPDATES.") p("IF THE BUTTON SAYS \"OPEN\" CLOSE THE STORE WITHOUT UPDATING OR OPENING ANYTHING.") p("WHEN COMPLETE, PUSH {ENTER}") input("...") # start_surface_app() # 1 operation 1 test # update_surface_app(False) # 1 test 2 operations (Run a second time because need to test to see if surface app is ready) # set_pen_settings() # 1 operation p("Ran 2 checks 8 operations 3 tests") def change_weather(): script = """send, {Lwin} sleep, 1500 send, Weather App sleep, 2000 send, {enter} sleep, 2000 send, {tab 2}98052{enter}""" BetaScript(script) time.sleep(2)
) def escape_unknown_persons(text): escaped = [] curr = 0 for match in re.finditer(r'(@)([_0-9A-Za-z]+)', text): if match.group(2) not in friend_screennames: span = match.span(1) assert text[span[0]:span[1]] == '@' escaped.append(text[curr:span[0]]) curr = span[1] escaped.append(text[curr:]) return u'$'.join(escaped) teri_age_str = util.age_str(19790608, u'誕生日男子') if util.p(50): teri_age_str = u'人間で言うとおよそ' + teri_age_str nicknames_teri = ( u'てりやき', u'テリー', u'ててて', u'うひひ', u'弁当男子', u'大人コミック', teri_age_str, teri_age_str, teri_age_str, u'терияки', u'越後製菓', u'ブラジル', u'ポンコツおじさん', u'おおひら村',
from util import do, p, BetaScript, kill, usernames import subprocess, time, os, os.path p("Importing s_09!") def s_09(): pin_items() pin_cortana() BetaScript("send {Lwin}") time.sleep(.9) resize_cio() p("Ran 2 checks 2 operations 5 iterations 0 tests") def resize_cio(): script = """ send {LWin} sleep 900 click 723, 303 sleep 900 send #{up} """ BetaScript(script) time.sleep(1) kill() def pin_cortana(): script = """
from util import do, p, BetaScript, kill, usernames, AlphaScript import subprocess, time, os, os.path p("Importing s_07!") def s_07(): set_username() # 1 operation p("Ran 0 checks 2 operations 0 tests") def set_username(): script = """ send #{up} sleep 500 click 547 350 sleep 500 send {fname} {lname} sleep 500 send {enter} """ do("control userpasswords", "ignore") time.sleep(2) BetaScript(script.format(fname=usernames()['fname'], lname=usernames()['lname'], enter='{enter}', up='{up}')) time.sleep(1) kill() # def side_load(): # do('powershell -ExecutionPolicy Bypass "D:\\App\\Add-AppDevPackage.ps1" -action install -bypass true -section all', 'ignore')
def s_07(): set_username() # 1 operation p("Ran 0 checks 2 operations 0 tests")
def selectHintsPrefPane(): "Select the Hints preferences pane by name." _selectPrefPane(p("HintsPaneTitle.png"))
def check_hw_config(host_cfg: Path, hardware_cfg: Path, old_hardware_cfg: Path) -> None: """Check that ``hardware_cfg`` exists and ``old_hardware_cfg`` doesn't. Also imports ``hardware_cfg`` in ``cfg`` if it's not otherwise imported. """ # `old_hardware_cfg` is repo_root / "hardware-configuration.nix"; NixOS # might generate one by default while installing, so this check should stay # here even though all of my hosts have been using this script for a while # now. if old_hardware_cfg.is_symlink(): warn( f"{p(old_hardware_cfg)} is a symlink to " + p(hardware_cfg.parent / os.readlink(old_hardware_cfg)) ) warn("That's probably not needed; consider deleting it.") elif old_hardware_cfg.exists(): if not hardware_cfg.exists(): info( f"{p(old_hardware_cfg)} exists but {p(hardware_cfg)}" + f" doesn't, renaming {p(old_hardware_cfg)}." ) if not DRY_RUN: old_hardware_cfg.rename(hardware_cfg) else: if filecmp.cmp(hardware_cfg, old_hardware_cfg): info( f"{p(old_hardware_cfg)} and {p(hardware_cfg)} " + "both exist but have the same contents, removing " + p(old_hardware_cfg) ) if not DRY_RUN: old_hardware_cfg.unlink() else: error( f"{p(old_hardware_cfg)} and {p(hardware_cfg)} " + "both exist but have different contents." ) error( f"Determine which one is correct and move it to {p(hardware_cfg)}, " + f"and then delete {p(old_hardware_cfg)}" ) # Otherwise, if we don't have a hardware configuration yet, generate one. if not hardware_cfg.exists(): update_hw_config_force(hardware_cfg) # `hardware_cfg`, relative to `cfg`, in a nix-import-friendly manner hardware_cfg_rel = f"./{hardware_cfg.name}" cfg_text = host_cfg.read_text(encoding="utf-8") if hardware_cfg_rel in cfg_text: dbg(f"It looks like {p(host_cfg)} already imports {p(hardware_cfg)}") else: info(f"{p(host_cfg)} doesn't import {p(hardware_cfg)}, attempting to add it") # Make the substitution... new_cfg_text, found_imports = re.subn( r"^\s*imports\s*=\s*\[", r"\g<0> " + hardware_cfg_rel + " ", cfg_text, count=1, flags=re.MULTILINE, ) if not found_imports: error( f"Couldn't find a suitable import statement in {p(host_cfg)}; " + f"make sure to add an import to {p(hardware_cfg)}" ) else: info(f"Writing and reformatting {p(host_cfg)}") if not DRY_RUN: host_cfg.write_text(new_cfg_text) nixfmt_output = get_output(["nixfmt", str(host_cfg)]) if nixfmt_output: dbg("nixfmt reported:") for line in nixfmt_output.splitlines(): dbg(line)
def firstPrefPane(region, title): "Click in the text pane to the left of the region and wait for title to show up." r = region.left(100).right(100) r.click() type(Key.TAB) region.wait(p(title))
def _prefTitleRegion(): return find(p("PreferencesTitle.png")).below(40).right(1).left(350)
def selectKeyBindingsPane(): "Select the Key Bindings preferences pane by name." _selectPrefPane(p("KeyBindingsPaneTitle.png"))
def selectVisualThemePrefPane(): "Select the Visual Theme preferences pane by name." _selectPrefPane(p("VisualThemePaneTitle.png"))
def selectUpdatePrefPane(): "Select the Update preferences pane by name." _selectPrefPane(p("UpdatePaneTitle.png"))
def selectRunandDebugPrefPane(): "Select the Run and Debug preferences pane by name." _selectPrefPane(p("RunandDebugPaneTitle.png"))
def nextPrefPane(region, title): "Select the next item down in the list and wait for title to show up in the region." type(Key.DOWN) wait(0.5) region.wait(p(title), 10)
from util import do, p, BetaScript, kill, usernames import subprocess, time, os, os.path p("Importing s_08!") def s_08(): if input( "Do you want to clear tiles? If no, will start pinning operation. (y/N)" ).lower().startswith("y"): clear_tiles() # 1 operation time.sleep(.2) input( "press {enter} when startmenu (AND TASKBAR DOES NOT CONTAIN ANY APPS EXCEPT FOR EDGE, EXPLORER AND STORE) is empty" ) add_first_block() time.sleep(.2) add_second_block() time.sleep(.2) add_third_block() time.sleep(.2) add_fourth_block() time.sleep(.2) add_fifth_block() time.sleep(.2) add_sixth_block() p("Ran 0 checks 1 operation @ 27 iterations 0 tests") def add_sixth_block():
def selectEditorPrefPane(): "Select the Editor preferences pane by name." _selectPrefPane(p("EditorPaneTitle.png"))