Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3: xrange got removed from python 3 #1413

Merged
merged 1 commit into from
Jul 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"Click>=6.2,<6.3",
"awesome-slugify>=1.6.5,<1.7",
"feedparser>=5.2.1,<5.3",
"chainmap>=1.0.2,<1.1"
"chainmap>=1.0.2,<1.1",
"future>=0.15,<0.16"
]

# Additional requirements for optional install options
Expand Down
7 changes: 4 additions & 3 deletions src/octoprint/plugins/cura/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


import re
from builtins import range

class SupportLocationTypes(object):
NONE = "none"
Expand Down Expand Up @@ -496,7 +497,7 @@ def from_cura_ini(cls, path):
if not key in result:
result[key] = []
if len(result[key]) <= index:
for n in xrange(index - len(result[key]) + 1):
for n in range(index - len(result[key]) + 1):
result[key].append(None)
result[key][index] = value
else:
Expand Down Expand Up @@ -549,7 +550,7 @@ def merge_profile_key(cls, key, profile, overrides=None):
# So override > profile > default, if neither override nor profile value are available
# the default value should just be left as is

for x in xrange(len(result)):
for x in range(len(result)):
if override_value is not None and x < len(override_value) and override_value[x] is not None:
# we have an override value for this location, so we use it
result[x] = override_value[x]
Expand Down Expand Up @@ -811,7 +812,7 @@ def temp_line(temp, extruder, template):

prefix_preheat = ""
prefix_waitheat = ""
for n in xrange(0, extruder_count):
for n in range(0, extruder_count):
if n > 0:
prefix_preheat += temp_line(temp, n, "M104 T{extruder} S{temp}\n")
prefix_waitheat += temp_line(temp, n, "M109 T{extruder} S{temp}\n")
Expand Down
9 changes: 5 additions & 4 deletions src/octoprint/plugins/discovery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import logging
import os
import flask
from builtins import range

import octoprint.plugin
import octoprint.util
Expand Down Expand Up @@ -409,7 +410,7 @@ def browse():
"HOST: {mcast_addr}:{mcast_port}\r\n\r\n"
])

for _ in xrange(retries):
for _ in range(retries):
for addr in octoprint.util.interface_addresses():
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
Expand All @@ -420,7 +421,7 @@ def browse():
message = search_message.format(query=query,
mcast_addr=self.__class__.ssdp_multicast_addr,
mcast_port=self.__class__.ssdp_multicast_port)
for _ in xrange(2):
for _ in range(2):
sock.sendto(message, (self.__class__.ssdp_multicast_addr, self.__class__.ssdp_multicast_port))

try:
Expand Down Expand Up @@ -541,7 +542,7 @@ def _ssdp_unregister(self):

self._ssdp_monitor_active = False
if self.host and self.port:
for _ in xrange(2):
for _ in range(2):
self._ssdp_notify(alive=False)

def _ssdp_notify(self, alive=True):
Expand Down Expand Up @@ -587,7 +588,7 @@ def _ssdp_notify(self, alive=True):
nts="ssdp:alive" if alive else "ssdp:byebye",
mcast_addr=self.__class__.ssdp_multicast_addr,
mcast_port=self.__class__.ssdp_multicast_port)
for _ in xrange(2):
for _ in range(2):
# send twice, stuff might get lost, it's only UDP
sock.sendto(message, (self.__class__.ssdp_multicast_addr, self.__class__.ssdp_multicast_port))
except:
Expand Down
5 changes: 3 additions & 2 deletions src/octoprint/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from watchdog.observers import Observer
from watchdog.observers.polling import PollingObserver
from collections import defaultdict
from builtins import range

import os
import logging
Expand Down Expand Up @@ -330,7 +331,7 @@ def template_disabled(name, plugin):
import string
from random import choice
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
secret_key = "".join(choice(chars) for _ in xrange(32))
secret_key = "".join(choice(chars) for _ in range(32))
self._settings.set(["server", "secretKey"], secret_key)
self._settings.save()
app.secret_key = secret_key
Expand Down Expand Up @@ -917,7 +918,7 @@ def _setup_assets(self):
# that might be caused by the user still having the folder open somewhere, let's try again after
# waiting a bit
import time
for n in xrange(3):
for n in range(3):
time.sleep(0.5)
self._logger.debug("Creating {path}: Retry #{retry} after {time}s".format(path=path, retry=n+1, time=(n + 1)*0.5))
try:
Expand Down
5 changes: 3 additions & 2 deletions src/octoprint/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import uuid

import logging
from builtins import range

from octoprint.settings import settings

Expand Down Expand Up @@ -107,7 +108,7 @@ def createPasswordHash(password, salt=None):
import string
from random import choice
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
salt = "".join(choice(chars) for _ in xrange(32))
salt = "".join(choice(chars) for _ in range(32))
settings().set(["accessControl", "salt"], salt)
settings().save()

Expand Down Expand Up @@ -506,7 +507,7 @@ def __init__(self, user):
import random
import time
chars = string.ascii_uppercase + string.ascii_lowercase + string.digits
self._session = "".join(random.choice(chars) for _ in xrange(10))
self._session = "".join(random.choice(chars) for _ in range(10))
self._created = time.time()

def __getattribute__(self, item):
Expand Down
5 changes: 3 additions & 2 deletions src/octoprint/util/avr_isp/intelHex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
from builtins import range

def readHex(filename):
data = []
Expand All @@ -14,7 +15,7 @@ def readHex(filename):
if len(line) != recLen * 2 + 11:
raise Exception("Error in hex file: " + line)
checkSum = 0
for i in xrange(0, recLen + 5):
for i in range(0, recLen + 5):
checkSum += int(line[i*2+1:i*2+3], 16)
checkSum &= 0xFF
if checkSum != 0:
Expand All @@ -23,7 +24,7 @@ def readHex(filename):
if recType == 0:#Data record
while len(data) < addr + recLen:
data.append(0)
for i in xrange(0, recLen):
for i in range(0, recLen):
data[addr + i] = int(line[i*2+9:i*2+11], 16)
elif recType == 1: #End Of File record
pass
Expand Down
7 changes: 4 additions & 3 deletions src/octoprint/util/avr_isp/stk500v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from serial import Serial
from serial import SerialException
from builtins import range

import ispBase, intelHex

Expand Down Expand Up @@ -67,7 +68,7 @@ def writeFlash(self, flashData):
self.sendMessage([0x06, 0x00, 0x00, 0x00, 0x00])

loadCount = (len(flashData) + pageSize - 1) / pageSize
for i in xrange(0, loadCount):
for i in range(0, loadCount):
recv = self.sendMessage([0x13, pageSize >> 8, pageSize & 0xFF, 0xc1, 0x0a, 0x40, 0x4c, 0x20, 0x00, 0x00] + flashData[(i * pageSize):(i * pageSize + pageSize)])
if self.progressCallback != None:
self.progressCallback(i + 1, loadCount*2)
Expand All @@ -81,11 +82,11 @@ def verifyFlash(self, flashData):
self.sendMessage([0x06, 0x00, 0x00, 0x00, 0x00])

loadCount = (len(flashData) + 0xFF) / 0x100
for i in xrange(0, loadCount):
for i in range(0, loadCount):
recv = self.sendMessage([0x14, 0x01, 0x00, 0x20])[2:0x102]
if self.progressCallback != None:
self.progressCallback(loadCount + i + 1, loadCount*2)
for j in xrange(0, 0x100):
for j in range(0, 0x100):
if i * 0x100 + j < len(flashData) and flashData[i * 0x100 + j] != recv[j]:
raise ispBase.IspError('Verify error at: 0x%x' % (i * 0x100 + j))

Expand Down