prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>check_key_import.py<|end_file_name|><|fim▁begin|>'''Manual check (not a discoverable unit test) for the key import, to identify problems with gnupg, gpg, gpg1, gpg2 and so on''' import os import shutil from gnupg import GPG def setup_keyring(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg CRYPTO = setup_keyring("keyringtest") if CRYPTO: print("Ready", CRYPTO) KEY_LIST = CRYPTO.list_keys(False) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of public keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) KEY_LIST = CRYPTO.list_keys(True) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of private keys:", NUM_KEYS) if NUM_KEYS < 1: <|fim_middle|> <|fim▁end|>
print("ERROR: Number of keys should be 1, not", NUM_KEYS)
<|file_name|>check_key_import.py<|end_file_name|><|fim▁begin|>'''Manual check (not a discoverable unit test) for the key import, to identify problems with gnupg, gpg, gpg1, gpg2 and so on''' import os import shutil from gnupg import GPG def <|fim_middle|>(keyring_name): '''Setup the keyring''' keyring_path = os.path.join("test", "outputdata", keyring_name) # Delete the entire keyring shutil.rmtree(keyring_path, ignore_errors=True) os.makedirs(keyring_path) gpg = GPG(gnupghome=keyring_path, gpgbinary="gpg") for key_name in ["key1_private", "key1_public"]: with open(os.path.join("test", "inputdata", key_name + ".txt"), "r") as keyfile: key_str = "".join(keyfile.readlines()) import_result = gpg.import_keys(key_str) print("Import result:", type(import_result)) print(import_result.__dict__) if import_result.count == 1 and len(set(import_result.fingerprints)) == 1: print("Got one import result") return gpg CRYPTO = setup_keyring("keyringtest") if CRYPTO: print("Ready", CRYPTO) KEY_LIST = CRYPTO.list_keys(False) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of public keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) KEY_LIST = CRYPTO.list_keys(True) NUM_KEYS = len(KEY_LIST) if KEY_LIST else 0 print("Number of private keys:", NUM_KEYS) if NUM_KEYS < 1: print("ERROR: Number of keys should be 1, not", NUM_KEYS) <|fim▁end|>
setup_keyring
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__()<|fim▁hole|> now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor)<|fim▁end|>
self._program = program self._timeOfDay = timeOfDay def run(self):
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): <|fim_middle|> <|fim▁end|>
def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor)
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): <|fim_middle|> def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
super().__init__() self._program = program self._timeOfDay = timeOfDay
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): <|fim_middle|> def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run()
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): <|fim_middle|> def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent)
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): <|fim_middle|> def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
self._colorSetter = colorSetter self._program.setColorSetter(colorSetter)
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): <|fim_middle|> def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
return self._program.getCurrentColor()
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): <|fim_middle|> <|fim▁end|>
self._program.setLastColor(lastColor)
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: <|fim_middle|> else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
sleepDuration = self._timeOfDay - secondsInCurrentDay
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: <|fim_middle|> logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def <|fim_middle|>(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
__init__
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def <|fim_middle|>(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
run
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def <|fim_middle|>(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
setThreadStopEvent
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def <|fim_middle|>(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
setColorSetter
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def <|fim_middle|>(self): return self._program.getCurrentColor() def setLastColor(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
getCurrentColor
<|file_name|>scheduledprogram.py<|end_file_name|><|fim▁begin|># Copyright (c) 2016 Sebastian Kanis # This file is part of pi-led-control. # pi-led-control is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # pi-led-control 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 pi-led-control. If not, see <http://www.gnu.org/licenses/>. import datetime import logging from server.programs.abstractprogram import AbstractProgram class ScheduledProgram(AbstractProgram): def __init__(self, program, timeOfDay): super().__init__() self._program = program self._timeOfDay = timeOfDay def run(self): now = datetime.datetime.now() secondsInCurrentDay = now.hour * 3600 + now.minute * 60 + now.second if secondsInCurrentDay < self._timeOfDay: sleepDuration = self._timeOfDay - secondsInCurrentDay else: sleepDuration = self._timeOfDay + 3600 * 24 - secondsInCurrentDay logging.getLogger("main").info("sleeping for " + str(sleepDuration) + " seconds") self._waitIfNotStopped(sleepDuration) self._program.run() def setThreadStopEvent(self, threadStopEvent): self.threadStopEvent = threadStopEvent self._program.setThreadStopEvent(threadStopEvent) def setColorSetter(self, colorSetter): self._colorSetter = colorSetter self._program.setColorSetter(colorSetter) def getCurrentColor(self): return self._program.getCurrentColor() def <|fim_middle|>(self, lastColor): self._program.setLastColor(lastColor) <|fim▁end|>
setLastColor
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): <|fim▁hole|> s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output)<|fim▁end|>
@moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue):
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): <|fim_middle|> <|fim▁end|>
@moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output)
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): <|fim_middle|> @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output)
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): <|fim_middle|> @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False)
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): <|fim_middle|> @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called)
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): <|fim_middle|> @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False)
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): <|fim_middle|> @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should")
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): <|fim_middle|> @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't")
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): <|fim_middle|> @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket'])
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): <|fim_middle|> <|fim▁end|>
CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output)
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def <|fim_middle|>(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
test_deploy
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def <|fim_middle|>(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
test_promote
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def <|fim_middle|>(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
test_promoting_same_version
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def <|fim_middle|>(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
test_sigv4
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def <|fim_middle|>(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
test_deploy_to_custom_environment
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def <|fim_middle|>(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
test_deploy_without_updating_the_environment
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def <|fim_middle|>(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def test_promote_to_custom_environment(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
test_deploy_to_custom_bucket
<|file_name|>test_cli.py<|end_file_name|><|fim▁begin|>import boto import mock import moto import tempfile import unittest from click.testing import CliRunner from rubberjackcli.click import rubberjack class CLITests(unittest.TestCase): @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy(self, cav, ue): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promote(self, ue, de): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('sys.exit') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_promoting_same_version(self, ue, de, se): de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': 'laterpay-devnull-live', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'same', }, ], }, }, } CliRunner().invoke(rubberjack, ['promote'], catch_exceptions=False) self.assertTrue(se.called) @moto.mock_s3_deprecated def test_sigv4(self): CliRunner().invoke(rubberjack, ['--sigv4-host', 'foo', 'deploy'], catch_exceptions=False) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--environment', 'wibble', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_without_updating_the_environment(self, ue, cav): s3 = boto.connect_s3() s3.create_bucket("laterpay-rubberjack-ebdeploy") # FIXME Remove hardcoded bucket name with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['deploy', '--no-update-environment', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 0, "update_environment was called, but it shouldn't") @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.create_application_version') @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') def test_deploy_to_custom_bucket(self, ue, cav): bucket_name = 'rbbrjck-test' s3 = boto.connect_s3() s3.create_bucket(bucket_name) with tempfile.NamedTemporaryFile() as tmp: result = CliRunner().invoke(rubberjack, ['--bucket', bucket_name, 'deploy', tmp.name], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) self.assertEqual(cav.call_count, 1, "create_application_version wasn't called, but it should") self.assertEqual(ue.call_count, 1, "update_environment wasn't called, but it should") _, cav_kwargs = cav.call_args self.assertEqual(bucket_name, cav_kwargs['s3_bucket']) @moto.mock_s3_deprecated @mock.patch('boto.beanstalk.layer1.Layer1.update_environment') @mock.patch('boto.beanstalk.layer1.Layer1.describe_environments') def <|fim_middle|>(self, de, ue): CUSTOM_TO_ENVIRONMENT = "loremipsum" de.return_value = { 'DescribeEnvironmentsResponse': { 'DescribeEnvironmentsResult': { 'Environments': [ { 'EnvironmentName': CUSTOM_TO_ENVIRONMENT, 'VersionLabel': 'old', }, { 'EnvironmentName': 'laterpay-devnull-dev', # FIXME Remove hardcoded EnvName 'VersionLabel': 'new', }, ], }, }, } result = CliRunner().invoke(rubberjack, ['promote', '--to-environment', CUSTOM_TO_ENVIRONMENT], catch_exceptions=False) self.assertEquals(result.exit_code, 0, result.output) <|fim▁end|>
test_promote_to_custom_environment
<|file_name|>test_paralleltools.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2.7 # -*- coding: utf-8 -*-<|fim▁hole|> import sys from src.paralleltools import Parallel #------------------------------------------------------------------------- # # conftools.py is a simple module to manage .xml configuration files # #------------------------------------------------------------------------- if __name__ == '__main__': """ VARIABLES """ args = sys.argv config_file_name = args[1] """ CODE """ parallel = Parallel() parallel.create_config_files(config_file_name)<|fim▁end|>
__author__ = """Co-Pierre Georg ([email protected])"""
<|file_name|>test_paralleltools.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- __author__ = """Co-Pierre Georg ([email protected])""" import sys from src.paralleltools import Parallel #------------------------------------------------------------------------- # # conftools.py is a simple module to manage .xml configuration files # #------------------------------------------------------------------------- if __name__ == '__main__': <|fim_middle|> <|fim▁end|>
""" VARIABLES """ args = sys.argv config_file_name = args[1] """ CODE """ parallel = Parallel() parallel.create_config_files(config_file_name)
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1):<|fim▁hole|> def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c<|fim▁end|>
r = self.nr - 2 return self.indx(r, c)
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): <|fim_middle|> <|fim▁end|>
def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): <|fim_middle|> def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
self.nr = nr self.nc = nc
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): <|fim_middle|> def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c)
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): <|fim_middle|> def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c)
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): <|fim_middle|> def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c)
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): <|fim_middle|> def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c)
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): <|fim_middle|> def indx(self, r, c): return r * self.nc + c <|fim▁end|>
i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): <|fim_middle|> <|fim▁end|>
return r * self.nc + c
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: <|fim_middle|> if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
r = 0
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): <|fim_middle|> return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
r = 0
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: <|fim_middle|> if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
r = self.nr - 1
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): <|fim_middle|> return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
r = self.nr - 2
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: <|fim_middle|> if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
c = 0
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): <|fim_middle|> return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
c = 0
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: <|fim_middle|> if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
c = self.nc - 1
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): <|fim_middle|> return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
c = self.nc - 2
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: <|fim_middle|> i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
return r, c
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def <|fim_middle|>(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
__init__
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def <|fim_middle|>(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
inc_r
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def <|fim_middle|>(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
dec_r
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def <|fim_middle|>(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
inc_c
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def <|fim_middle|>(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
dec_c
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def <|fim_middle|>(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def indx(self, r, c): return r * self.nc + c <|fim▁end|>
row_col
<|file_name|>rc_skip_last.py<|end_file_name|><|fim▁begin|>""" Follow Me activity for Sugar Copyright (C) 2010 Peter Hewitt This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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/>. """ class RC(): def __init__(self, nr, nc): self.nr = nr self.nc = nc def inc_r(self, ind): r, c = self.row_col(ind) r += 1 if r == self.nr: r = 0 if r == (self.nr - 1) and c == (self.nc - 1): r = 0 return self.indx(r, c) def dec_r(self, ind): r, c = self.row_col(ind) r -= 1 if r < 0: r = self.nr - 1 if r == (self.nr - 1) and c == (self.nc - 1): r = self.nr - 2 return self.indx(r, c) def inc_c(self, ind): r, c = self.row_col(ind) c += 1 if c == self.nc: c = 0 if r == (self.nr - 1) and c == (self.nc - 1): c = 0 return self.indx(r, c) def dec_c(self, ind): r, c = self.row_col(ind) c -= 1 if c < 0: c = self.nc - 1 if r == (self.nr - 1) and c == (self.nc - 1): c = self.nc - 2 return self.indx(r, c) def row_col(self, ind): i = 0 for r in range(self.nr): for c in range(self.nc): if i == ind: return r, c i += 1 def <|fim_middle|>(self, r, c): return r * self.nc + c <|fim▁end|>
indx
<|file_name|>d6ae359ab0d6_add_tenant_id_to_lcm_subscriptions_and_.py<|end_file_name|><|fim▁begin|># Copyright 2022 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at<|fim▁hole|># # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # """add tenant_id to lcm_subscriptions and lcm_op_occs Revision ID: d6ae359ab0d6 Revises: 3ff50553e9d3 Create Date: 2022-01-06 13:35:53.868106 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = 'd6ae359ab0d6' down_revision = '3ff50553e9d3' def upgrade(active_plugins=None, options=None): op.add_column('vnf_lcm_subscriptions', sa.Column('tenant_id', sa.String(length=64), nullable=False)) op.add_column('vnf_lcm_op_occs', sa.Column('tenant_id', sa.String(length=64), nullable=False))<|fim▁end|>
<|file_name|>d6ae359ab0d6_add_tenant_id_to_lcm_subscriptions_and_.py<|end_file_name|><|fim▁begin|># Copyright 2022 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # """add tenant_id to lcm_subscriptions and lcm_op_occs Revision ID: d6ae359ab0d6 Revises: 3ff50553e9d3 Create Date: 2022-01-06 13:35:53.868106 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = 'd6ae359ab0d6' down_revision = '3ff50553e9d3' def upgrade(active_plugins=None, options=None): <|fim_middle|> <|fim▁end|>
op.add_column('vnf_lcm_subscriptions', sa.Column('tenant_id', sa.String(length=64), nullable=False)) op.add_column('vnf_lcm_op_occs', sa.Column('tenant_id', sa.String(length=64), nullable=False))
<|file_name|>d6ae359ab0d6_add_tenant_id_to_lcm_subscriptions_and_.py<|end_file_name|><|fim▁begin|># Copyright 2022 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # """add tenant_id to lcm_subscriptions and lcm_op_occs Revision ID: d6ae359ab0d6 Revises: 3ff50553e9d3 Create Date: 2022-01-06 13:35:53.868106 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = 'd6ae359ab0d6' down_revision = '3ff50553e9d3' def <|fim_middle|>(active_plugins=None, options=None): op.add_column('vnf_lcm_subscriptions', sa.Column('tenant_id', sa.String(length=64), nullable=False)) op.add_column('vnf_lcm_op_occs', sa.Column('tenant_id', sa.String(length=64), nullable=False)) <|fim▁end|>
upgrade
<|file_name|>gen_user_followers.py<|end_file_name|><|fim▁begin|>from datetime import * from Tweetstream import * from UserAnalyser import * from TimeAnalyser import * import math import sys import pickle #Frequency over the common def load_list(filein): d = dict() for l in filein: l = eval(l) d[l[0]] = l[1] return d if __name__ == "__main__": follow = load_list(open(sys.argv[5], 'r')) keywords = open(sys.argv[2], 'r').readline().strip("\n").split(",") userstream = Tweetstream(jsonfilee=sys.argv[3], jsonformat=False, keywords=keywords)<|fim▁hole|> ua = UserAnalyser (sys.argv[4], keywords = keywords) ua.load_usersVectors() ua.load_idf() ua.load_usersScore() rank = dict() # normalizar pelo numero de kw no topic vector c = 0 for t in userstream: rank[t['id']] = 0 n = 0 if t['user_id'] in follow: c += 1 for fuser in follow[t['user_id']]: if fuser in ua.usersScore: rank[t['id']] += ua.usersScore[fuser] n += 1 if n > 0: rank[t['id']] /= n print c #prinit score, nwindow pickle.dump(rank, open(sys.argv[4]+"_rank_USER_followers.pick", 'w'), pickle.HIGHEST_PROTOCOL)<|fim▁end|>
topicstream = Tweetstream(jsonfilee=sys.argv[1], jsonformat=False, keywords=keywords)
<|file_name|>gen_user_followers.py<|end_file_name|><|fim▁begin|>from datetime import * from Tweetstream import * from UserAnalyser import * from TimeAnalyser import * import math import sys import pickle #Frequency over the common def load_list(filein): <|fim_middle|> if __name__ == "__main__": follow = load_list(open(sys.argv[5], 'r')) keywords = open(sys.argv[2], 'r').readline().strip("\n").split(",") userstream = Tweetstream(jsonfilee=sys.argv[3], jsonformat=False, keywords=keywords) topicstream = Tweetstream(jsonfilee=sys.argv[1], jsonformat=False, keywords=keywords) ua = UserAnalyser (sys.argv[4], keywords = keywords) ua.load_usersVectors() ua.load_idf() ua.load_usersScore() rank = dict() # normalizar pelo numero de kw no topic vector c = 0 for t in userstream: rank[t['id']] = 0 n = 0 if t['user_id'] in follow: c += 1 for fuser in follow[t['user_id']]: if fuser in ua.usersScore: rank[t['id']] += ua.usersScore[fuser] n += 1 if n > 0: rank[t['id']] /= n print c #prinit score, nwindow pickle.dump(rank, open(sys.argv[4]+"_rank_USER_followers.pick", 'w'), pickle.HIGHEST_PROTOCOL) <|fim▁end|>
d = dict() for l in filein: l = eval(l) d[l[0]] = l[1] return d
<|file_name|>gen_user_followers.py<|end_file_name|><|fim▁begin|>from datetime import * from Tweetstream import * from UserAnalyser import * from TimeAnalyser import * import math import sys import pickle #Frequency over the common def load_list(filein): d = dict() for l in filein: l = eval(l) d[l[0]] = l[1] return d if __name__ == "__main__": <|fim_middle|> <|fim▁end|>
follow = load_list(open(sys.argv[5], 'r')) keywords = open(sys.argv[2], 'r').readline().strip("\n").split(",") userstream = Tweetstream(jsonfilee=sys.argv[3], jsonformat=False, keywords=keywords) topicstream = Tweetstream(jsonfilee=sys.argv[1], jsonformat=False, keywords=keywords) ua = UserAnalyser (sys.argv[4], keywords = keywords) ua.load_usersVectors() ua.load_idf() ua.load_usersScore() rank = dict() # normalizar pelo numero de kw no topic vector c = 0 for t in userstream: rank[t['id']] = 0 n = 0 if t['user_id'] in follow: c += 1 for fuser in follow[t['user_id']]: if fuser in ua.usersScore: rank[t['id']] += ua.usersScore[fuser] n += 1 if n > 0: rank[t['id']] /= n print c #prinit score, nwindow pickle.dump(rank, open(sys.argv[4]+"_rank_USER_followers.pick", 'w'), pickle.HIGHEST_PROTOCOL)
<|file_name|>gen_user_followers.py<|end_file_name|><|fim▁begin|>from datetime import * from Tweetstream import * from UserAnalyser import * from TimeAnalyser import * import math import sys import pickle #Frequency over the common def load_list(filein): d = dict() for l in filein: l = eval(l) d[l[0]] = l[1] return d if __name__ == "__main__": follow = load_list(open(sys.argv[5], 'r')) keywords = open(sys.argv[2], 'r').readline().strip("\n").split(",") userstream = Tweetstream(jsonfilee=sys.argv[3], jsonformat=False, keywords=keywords) topicstream = Tweetstream(jsonfilee=sys.argv[1], jsonformat=False, keywords=keywords) ua = UserAnalyser (sys.argv[4], keywords = keywords) ua.load_usersVectors() ua.load_idf() ua.load_usersScore() rank = dict() # normalizar pelo numero de kw no topic vector c = 0 for t in userstream: rank[t['id']] = 0 n = 0 if t['user_id'] in follow: <|fim_middle|> if n > 0: rank[t['id']] /= n print c #prinit score, nwindow pickle.dump(rank, open(sys.argv[4]+"_rank_USER_followers.pick", 'w'), pickle.HIGHEST_PROTOCOL) <|fim▁end|>
c += 1 for fuser in follow[t['user_id']]: if fuser in ua.usersScore: rank[t['id']] += ua.usersScore[fuser] n += 1
<|file_name|>gen_user_followers.py<|end_file_name|><|fim▁begin|>from datetime import * from Tweetstream import * from UserAnalyser import * from TimeAnalyser import * import math import sys import pickle #Frequency over the common def load_list(filein): d = dict() for l in filein: l = eval(l) d[l[0]] = l[1] return d if __name__ == "__main__": follow = load_list(open(sys.argv[5], 'r')) keywords = open(sys.argv[2], 'r').readline().strip("\n").split(",") userstream = Tweetstream(jsonfilee=sys.argv[3], jsonformat=False, keywords=keywords) topicstream = Tweetstream(jsonfilee=sys.argv[1], jsonformat=False, keywords=keywords) ua = UserAnalyser (sys.argv[4], keywords = keywords) ua.load_usersVectors() ua.load_idf() ua.load_usersScore() rank = dict() # normalizar pelo numero de kw no topic vector c = 0 for t in userstream: rank[t['id']] = 0 n = 0 if t['user_id'] in follow: c += 1 for fuser in follow[t['user_id']]: if fuser in ua.usersScore: <|fim_middle|> if n > 0: rank[t['id']] /= n print c #prinit score, nwindow pickle.dump(rank, open(sys.argv[4]+"_rank_USER_followers.pick", 'w'), pickle.HIGHEST_PROTOCOL) <|fim▁end|>
rank[t['id']] += ua.usersScore[fuser] n += 1
<|file_name|>gen_user_followers.py<|end_file_name|><|fim▁begin|>from datetime import * from Tweetstream import * from UserAnalyser import * from TimeAnalyser import * import math import sys import pickle #Frequency over the common def load_list(filein): d = dict() for l in filein: l = eval(l) d[l[0]] = l[1] return d if __name__ == "__main__": follow = load_list(open(sys.argv[5], 'r')) keywords = open(sys.argv[2], 'r').readline().strip("\n").split(",") userstream = Tweetstream(jsonfilee=sys.argv[3], jsonformat=False, keywords=keywords) topicstream = Tweetstream(jsonfilee=sys.argv[1], jsonformat=False, keywords=keywords) ua = UserAnalyser (sys.argv[4], keywords = keywords) ua.load_usersVectors() ua.load_idf() ua.load_usersScore() rank = dict() # normalizar pelo numero de kw no topic vector c = 0 for t in userstream: rank[t['id']] = 0 n = 0 if t['user_id'] in follow: c += 1 for fuser in follow[t['user_id']]: if fuser in ua.usersScore: rank[t['id']] += ua.usersScore[fuser] n += 1 if n > 0: <|fim_middle|> print c #prinit score, nwindow pickle.dump(rank, open(sys.argv[4]+"_rank_USER_followers.pick", 'w'), pickle.HIGHEST_PROTOCOL) <|fim▁end|>
rank[t['id']] /= n
<|file_name|>gen_user_followers.py<|end_file_name|><|fim▁begin|>from datetime import * from Tweetstream import * from UserAnalyser import * from TimeAnalyser import * import math import sys import pickle #Frequency over the common def <|fim_middle|>(filein): d = dict() for l in filein: l = eval(l) d[l[0]] = l[1] return d if __name__ == "__main__": follow = load_list(open(sys.argv[5], 'r')) keywords = open(sys.argv[2], 'r').readline().strip("\n").split(",") userstream = Tweetstream(jsonfilee=sys.argv[3], jsonformat=False, keywords=keywords) topicstream = Tweetstream(jsonfilee=sys.argv[1], jsonformat=False, keywords=keywords) ua = UserAnalyser (sys.argv[4], keywords = keywords) ua.load_usersVectors() ua.load_idf() ua.load_usersScore() rank = dict() # normalizar pelo numero de kw no topic vector c = 0 for t in userstream: rank[t['id']] = 0 n = 0 if t['user_id'] in follow: c += 1 for fuser in follow[t['user_id']]: if fuser in ua.usersScore: rank[t['id']] += ua.usersScore[fuser] n += 1 if n > 0: rank[t['id']] /= n print c #prinit score, nwindow pickle.dump(rank, open(sys.argv[4]+"_rank_USER_followers.pick", 'w'), pickle.HIGHEST_PROTOCOL) <|fim▁end|>
load_list
<|file_name|>passphrases.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import Blueprint<|fim▁hole|> @route(bp, '/') def get(): p = Passphrase.get_random() return {"results": p}<|fim▁end|>
from jotonce.api import route from jotonce.passphrases.models import Passphrase bp = Blueprint('passphrase', __name__, url_prefix='/passphrase')
<|file_name|>passphrases.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import Blueprint from jotonce.api import route from jotonce.passphrases.models import Passphrase bp = Blueprint('passphrase', __name__, url_prefix='/passphrase') @route(bp, '/') def get(): <|fim_middle|> <|fim▁end|>
p = Passphrase.get_random() return {"results": p}
<|file_name|>passphrases.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- from flask import Blueprint from jotonce.api import route from jotonce.passphrases.models import Passphrase bp = Blueprint('passphrase', __name__, url_prefix='/passphrase') @route(bp, '/') def <|fim_middle|>(): p = Passphrase.get_random() return {"results": p} <|fim▁end|>
get
<|file_name|>messages.py<|end_file_name|><|fim▁begin|>import string import socket import base64<|fim▁hole|> if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb"<|fim▁end|>
import sys class message: def __init__(self, name="generate" ):
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: <|fim_middle|> class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): <|fim_middle|> def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded=""
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): <|fim_middle|> def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part <|fim_middle|> def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): <|fim_middle|> def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
return self.name
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): <|fim_middle|> def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
return self.decoded
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): <|fim_middle|> class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
self.decoded = decoded
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): <|fim_middle|> <|fim▁end|>
def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb"
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): <|fim_middle|> <|fim▁end|>
message.__init__( self , name) self.type="sb"
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": <|fim_middle|> else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
self.name=socket.gethostname()
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: <|fim_middle|> self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
self.name=name
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": <|fim_middle|> b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
return None
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def <|fim_middle|>(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
__init__
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def <|fim_middle|> ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
set
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def <|fim_middle|> ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
get
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def <|fim_middle|> (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
get_sendername
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def <|fim_middle|> ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
get_message
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def <|fim_middle|> ( self , decoded): self.decoded = decoded class shoutbox_message(message): def __init__(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
set_message
<|file_name|>messages.py<|end_file_name|><|fim▁begin|> import string import socket import base64 import sys class message: def __init__(self, name="generate" ): if name == "generate": self.name=socket.gethostname() else: self.name=name self.type="gc" self.decoded="" def set ( self, content=" " ): base64content = base64.b64encode ( content ) self.decoded="piratebox;"+ self.type + ";01;" + self.name + ";" + base64content def get ( self ): # TODO Split decoded part message_parts = string.split ( self.decoded , ";" ) if message_parts[0] != "piratebox": return None b64_content_part = message_parts[4] content = base64.b64decode ( b64_content_part ) return content def get_sendername (self): return self.name def get_message ( self ): return self.decoded def set_message ( self , decoded): self.decoded = decoded class shoutbox_message(message): def <|fim_middle|>(self, name="generate" ): message.__init__( self , name) self.type="sb" <|fim▁end|>
__init__
<|file_name|>check.py<|end_file_name|><|fim▁begin|>#-*- coding:utf-8 -*- from findbilibili import * #funtion name [checkinfo] #判断要输出的回答 #param array 抓取的文字 #return string 回答 def checkinfo2(content): content[1] = content[1].decode('gbk') key = content[1].encode('utf-8') if key == '节操': return '这种东西早就没有了' result = animation(key) #搜动漫<|fim▁hole|> return result #funtion name [animation] #搜索动漫 #param array 动漫名字 #return string 最后更新网址 def animation(name): url = bilibili(name) try: result = 'bilibili最后更新:第'+url[-1][0]+'集'+url[-1][1] return result except IndexError: return '什么都找不到!'<|fim▁end|>
<|file_name|>check.py<|end_file_name|><|fim▁begin|>#-*- coding:utf-8 -*- from findbilibili import * #funtion name [checkinfo] #判断要输出的回答 #param array 抓取的文字 #return string 回答 def checkinfo2(content): content[1] = content[1].decode<|fim_middle|> return string 最后更新网址 def animation(name): url = bilibili(name) try: result = 'bilibili最后更新:第'+url[-1][0]+'集'+url[-1][1] return result except IndexError: return '什么都找不到!'<|fim▁end|>
('gbk') key = content[1].encode('utf-8') if key == '节操': return '这种东西早就没有了' result = animation(key) #搜动漫 return result #funtion name [animation] #搜索动漫 #param array 动漫名字 #
<|file_name|>check.py<|end_file_name|><|fim▁begin|>#-*- coding:utf-8 -*- from findbilibili import * #funtion name [checkinfo] #判断要输出的回答 #param array 抓取的文字 #return string 回答 def checkinfo2(content): content[1] = content[1].decode('gbk') key = content[1].encode('utf-8') if key == '节操': return '这种东西早就没有了' result = animation(key) #搜动漫 return result #funtion name [animation] #搜索动漫 #param array 动漫名字 #return string 最后更新网址 def animation(name): url = bilibili(name) try: result = 'bilibili最后更新:第'+url[-1][0]+'集'+url[-1]<|fim_middle|> <|fim▁end|>
[1] return result except IndexError: return '什么都找不到!'
<|file_name|>check.py<|end_file_name|><|fim▁begin|>#-*- coding:utf-8 -*- from findbilibili import * #funtion name [checkinfo] #判断要输出的回答 #param array 抓取的文字 #return string 回答 def checkinfo2(content): content[1] = content[1].decode('gbk') key = content[1].encode('utf-8') if key == '节操': return '这种东西早就没有了' result = <|fim_middle|> sult #funtion name [animation] #搜索动漫 #param array 动漫名字 #return string 最后更新网址 def animation(name): url = bilibili(name) try: result = 'bilibili最后更新:第'+url[-1][0]+'集'+url[-1][1] return result except IndexError: return '什么都找不到!'<|fim▁end|>
animation(key) #搜动漫 return re